How can I output my PHP/SQL query results into an HTML table using PHP ?

  • Thread starter Thread starter JackSkellington
  • Start date Start date
J

JackSkellington

Guest
The query is simple: $photo_query="SELECT *
FROM photos
ORDER BY date_uploaded DESC";

The fields in table called "photos" are "id" and "photo_filename"

All I want is for all the photo filenames in the database to output to a 3-column table.

No headers... or anything complicated... simply 3 HTML columns listing every photo_filename... using PHP !!!
 
Try this..
(not tested)

$photo_query="SELECT *
FROM photos
ORDER BY date_uploaded DESC";

$result = mysql_query($photo_query);

echo "<table>";
while ($row = mysql_fetch_array(
$result, MYSQL_ASSOC)) {
echo "<tr>";
echo "<td>{$row['id']}</td>";
echo "<td>{$row['photo_filename']}</td>";
echo "<td>{$row['date_uploaded']}</td>";
echo "</tr>";
}
echo "</table>";

It's a start anyway!
 
Back
Top