Reputation: 1201
How can I list all users on sql to html page ? I used this code ;
$query = mysql_query("SELECT username FROM Users WHERE id<'".$row['id']."'");
$rowtwo = mysql_fetch_array($query) or die();
echo '<table>
<tr>
<td><font size="2" face="Lucida Sans Unicode" color=#EBEBEB>' .$rowtwo['username'].'</td>
</tr>
</table>';
NOTE: $row['id'] is current user id
Upvotes: 1
Views: 13302
Reputation: 948
try it like this:
get all users from database (in case u will get all, otherwise use your query):
$query = mysql_query("SELECT username FROM Users");
each user should be printed in his own row:
echo '<table>';
while($rowtwo = mysql_fetch_array($query)){
echo '<tr>
<td><font size="2" face="Lucida Sans Unicode" color=#EBEBEB>' .$rowtwo['username'].'</td>
</tr>';
}
echo '</table>';
the While loop is important to get only one row from the database after the other.
Upvotes: 3