Format into a table

I’d like to take the data that php is grabbing from my database and make it look more like an actual table. The table would have 4 columns and X rows. How can I do this? Here’s what my code currently looks like:

<a href="add.php">Add entry</a><br>
<br>
<?php

include("connect.php");

$query="SELECT * FROM food ";
$result=mysql_query($query);
$num = mysql_num_rows ($result);
mysql_close();

if ($num > 0 ) {
$i=0;
while ($i < $num) {
$smallfood = mysql_result($result,$i,"smallfood");
$bigfood = mysql_result($result,$i,"bigfood");
$hotfood = mysql_result($result,$i,"hotfood");
$coldfood = mysql_result($result,$i,"coldfood");
$id = mysql_result($result,$i,"id");

echo "<b>Price:</b> $smallfood<br>";
echo "<b>Drink:</b> $bigfoodk<br>";
echo "<b>Bar:</b> $hotfood<br>";
echo "<b>Time:</b> $coldfood<br>";
echo "<a href=\\"update.php?id=$id\\">Update</a> - <a href=\\"delete.php?id=$id\\">Delete</a>";
echo "<br><br>";

++$i; } } else { echo "The database is empty"; }?>

thanks

NVM, I got it. Thanks

Those both worked great, thanks guys! I went with blogtactic’s cause it was the layout I was looking for.

or try


    echo '<table>'; 

     echo '<tr>'; 
     echo "<td><b>Price:</b></td>"; 
     echo "<td><b>Drink:</b></td>"; 
     echo "<td><b>Bar:</b></td>"; 
     echo "<td><b>Time:</b></td>"; 
     echo "<td>Mode</td>"; 
     echo "</tr>"; 

    while ($i < $num) 
    { 
        $smallfood    = mysql_result($result,$i,"smallfood"); 
        $bigfood     = mysql_result($result,$i,"bigfood"); 
        $hotfood    = mysql_result($result,$i,"hotfood"); 
        $coldfood    = mysql_result($result,$i,"coldfood"); 
        $id            = mysql_result($result,$i,"id"); 

        echo '<tr>'; 
        echo "<td>.$smallfood</td>"; 
        echo "<td>.$bigfoodk</td>"; 
        echo "<td>.$hotfood</td>"; 
        echo "<td>.$coldfood</td>"; 
        echo "<td><a href=\\"update.php?id=$id\\">Update</a> - <a href=\\"delete.php?id=$id\\">Delete</a></td>"; 
        echo "</tr>"; 

        ++$i; 
    } 
     
    echo '</table>'; 

Try this

<a href="add.php">Add entry</a>

<br /> 
<br />  
<?php 

include("connect.php"); 

$query	= "SELECT * FROM food"; 
$result = mysql_query($query); 
$num	= mysql_num_rows ($result); 
mysql_close(); 

$i = 0; 

if ($num > 0)
{
	echo '<table>';

	while ($i < $num) 
	{
		$smallfood	= mysql_result($result,$i,"smallfood"); 
		$bigfood 	= mysql_result($result,$i,"bigfood"); 
		$hotfood	= mysql_result($result,$i,"hotfood"); 
		$coldfood	= mysql_result($result,$i,"coldfood"); 
		$id			= mysql_result($result,$i,"id"); 

		echo '<tr>';
		echo "<td><b>Price:</b> $smallfood</td>"; 
		echo "<td><b>Drink:</b> $bigfoodk</td>"; 
		echo "<td><b>Bar:</b> $hotfood</td>"; 
		echo "<td><b>Time:</b> $coldfood</td>"; 
		echo "<td><a href=\\"update.php?id=$id\\">Update</a> - <a href=\\"delete.php?id=$id\\">Delete</a></td>";
		echo "</tr>"; 

		++$i; 
	}
	
	echo '</table>';
}
else
echo "The database is empty";

?>