Php Query Not Showing All Results In Html Table
So I have the following query to show all users from my database:
Solution 1:
Remove line $row = mysql_fetch_array($result);
Because this line starts to fetching records from your query results. First fetched record is record with id 1
and you do nothing with it.
Then you start echo
ing other records, but record with id 1
is already skipped.
Solution 2:
You fetch the first row before your while loop is defined; once you enter the while loop it fetches the next row, which is the second. Remove the first mysql_fetch_array($result)
operation.
Incidentally, also, the original mysql
api in PHP is deprecated, it is recommended to use mysqli
instead.
Solution 3:
I think you should put it this way though
<?php$connection = mysql_connect('localhost', 'users', 'password'); //The Blank string is the password
mysql_select_db('users');
let all the connection be outside the "ul" tag.
$query = ("SELECT * FROM oneusers"); //You don't need a ; like you do in SQL$result = mysql_query($query);
$query = ("SELECT * FROM oneusers"); //You don't need a ; like you do in SQL$result = mysql_query($query);
$row=mysql_fetch_array($result);
?><ulclass="names"><table><tr><th>Navn</th><th>Email</th><th>Score</th></tr><?phpwhile($row){ //Creates a loop to loop through resultsecho"<tr><td>" . $row['iUserName'] . "</td><td>" . $row['iUserEmail'] . "</td><td>" . $row['iUserCash'] . " DKK</td></tr>"; //$row['index'] the index here is a field name
}
mysql_close(); //Make sure to close out the database connection?></table></ul>
Post a Comment for "Php Query Not Showing All Results In Html Table"