PHP dispaying data in table
PHP dispaying data in table
Another maybe easy question but I would like to display data from mysql database (like whole table) and I would like to display it in real table, when I do it now every single data are display in same row. I would like to do the list of members+ rank. I wrote it weird but I don't know how to explain it better. If anyone understands what I am talking about can you help me? Thanks
Re: PHP dispaying data in table
By "real" table I take it you mean a HTML table:
First, start your table with the HTML tag, fill it with the results, then close the table tag:
First, start your table with the HTML tag, fill it with the results, then close the table tag:
Code: Select all
<table>
<tr>
<th>Username</th>
<th>Rank</th>
</tr>
<?php
// Your query
$query = mysql_query("SELECT * FROM `users`");
// loop through the results
// $row = array of the row
while( $row = mysql_fetch_assoc($query) )
{
echo '<tr>'; // new HTML table row
echo '<td>' . $row['username'] . '</td>'; // column with username
echo '<td>' . $row['rank'] . '</td>'; // column with rank
echo '</tr>'; // close the HTML table row
}
?>
</table>
Fighting for peace is declaring war on war. If you want peace be peaceful.