first you need to convert your request to an array
include_once("abc.php");
$query = mysql_query('select * from dbts LIMIT 6');
$db = array();
while($row = mysql_fetch_array($query))
$db[] = $row;
then
echo'<table>';
$i=0;
for($i = 0; $i <= count($db); $i+=3){
echo '<tr>';
for($j = $i; $j < $i + 3; $j++)
if(isset($db[$j]))
echo '<td width="180" border="1" COLSPAN="2">' . $db[$j]['name'] . '</td>';
echo '</tr>';
echo '<tr>';
for($j = $i; $j < $i + 3; $j++){
if(isset($db[$j])){
echo '<td width="90">' . $db[$j]['image'] . '</td>';
echo '<td width="90">' . $db[$j]['image'] . '</td>';
}
}
echo '</tr>';
echo $i;
}
echo '</table>';
i uses if (isset ($ db [$ j])) to make sure this code will work, but if you know that you have 6 lines in your db, you do not need to use this
Kiyan source
share