PHP Echo Over 3 Columns and 2 Rows

Soldato
Joined
30 Nov 2005
Posts
3,084
Location
London
Im trying to do the following in PHP with a MySQL database:

tableao2.jpg


However, I just can't get it to Echo the values from the database into the next column and so on.

Basically the first value's name is echoed above a row that echo's it's description.

Hope that makes some kind of sense.
 
Each MySQL row has Row Name & Row Desc.

Then bascialy each of the two Values from the MySQL Row, is echoed from left to right in a Table like the one above.

It's like this code I found but can't seem to change it to do the above:

Code:
$x = 1; 
echo '<table><tr>'; 
while($row = mysql_fetch_object($result)){ 
echo "<td>$row->somevar</td>"; 
if($x%5 == 0){ 
echo '</tr><tr>'; 
} 
$x++; 
} 
echo '</tr></table>';
 
Last edited:
Edit: Fixed change $result for $row.

However, the table comes out not as expected.

The values are coming out next to each other rather than ontop.

This is what it looks like, when I'm trying to get it like the first image at the top of this page:

table2gy9.jpg
 
Last edited:
Back
Top Bottom