I want to take my users from my table and display them with a html table.i want their Name Avatar displayed. All of this information is in the table.
I want to display this in a table with 4 cols by as many rows needed.
This is my full code as asked for:
<html><head><title>MySQL Table Viewer</title></head><body>
<?php
$db_host = '';
$db_user = '';
$database = '';
$db_pwd = '';
$table = '';
if (!mysql_connect($db_host, $db_user, $db_pwd))
die("Can't connect to database");
if (!mysql_select_db($database))
die("Can't select database");
// sending query
$result = mysql_query("SELECT * FROM {$table} WHERE livedj=1");
if (!$result) {
die("Query to show fields from table failed");
}
$max_rows = 6;
$max_cols = 4;
echo "<table>";
$rows = 1;
while ($rows <= $max_rows)
{
echo "<tr>";
$cols = 1; // reset columns to 1 for each row
while ($cols <= $max_cols)
{
echo "<td>". $row['name'] . "<br />
<img src=\"http://myurl/path/to/pics/" . $row['avatar'] . "\" height=\"150\" width=\"150\" /></td>";
$cols++; // column counter
}
echo "</tr>";
$rows++; //row counter
}
echo "</table>";
?>
</body></html>
This only give out a page with the correct table made but it is not displaying any information from mysql…
and yes I have deleted the database and passwords settings here and my copy has the correct settings.
I hope you meant to say your SQL table has 6 data fields (7 with the ‘livedj’ you seem to be using in your WHERE clause), and as many data entries as needed.
I am also assuming you want your output to look something like this:
Then that code would be: