Knuckles Posted April 14, 2011 Share Posted April 14, 2011 When i use this code it show everything except for the first record in the table. I have also tried it with the users for the login system im using and then it doesnt show the person im logged in to or also the first record in the table and i need it too show all the records How do i solve this? I thought it had something to do with: <?php while ($rij = mysql_fetch_array($result)){ echo ("<tr><td>". $rij['ID'] . " </td> " . "<td>" . $rij['naam'] . " " . $rij['telefoon'] . " </td> " . "<td>" . $rij['adres'] . " </td> " . "<td>" . $rij['mobiel`'] . " </td>". "</td></tr>\n "); } ?> But i dont know how to solve it. <?php $con = mysql_connect("localhost","root",""); if (!$con) { die('Could not connect: ' . mysql_error()); } mysql_select_db("root123", $con); $sql= "SELECT * FROM root123 ORDER BY ID;"; $result = mysql_query($sql, $con); $rij = mysql_fetch_array($result); ?> <table width="80%" align="center"> <tr> <th>ID</th> <th width="150px">Naam</th> <th>Gebruikersnaam</th> <th width="300px">Wachtwoord</th> </tr> <?php while ($rij = mysql_fetch_array($result)){ echo ("<tr><td>". $rij['ID'] . " </td> " . "<td>" . $rij['naam'] . " " . $rij['telefoon'] . " </td> " . "<td>" . $rij['adres'] . " </td> " . "<td>" . $rij['mobiel`'] . " </td>". "</td></tr>\n "); } ?> </table> Quote Link to comment https://forums.phpfreaks.com/topic/233700-select-function-not-showing-all/ Share on other sites More sharing options...
requinix Posted April 14, 2011 Share Posted April 14, 2011 Ah, my spidey sense was right again. $rij = mysql_fetch_array($result); Get rid of that. Quote Link to comment https://forums.phpfreaks.com/topic/233700-select-function-not-showing-all/#findComment-1201488 Share on other sites More sharing options...
cyberRobot Posted April 14, 2011 Share Posted April 14, 2011 Ah, my spidey sense was right again. $rij = mysql_fetch_array($result); Get rid of that. Just to clarify, removing the first mysql_fetch_array() call should fix the issue. <?php ... $sql= "SELECT * FROM root123 ORDER BY ID;"; $result = mysql_query($sql, $con); $rij = mysql_fetch_array($result); //<--- REMOVE THIS ONE ... while ($rij = mysql_fetch_array($result)){ ... ?> Quote Link to comment https://forums.phpfreaks.com/topic/233700-select-function-not-showing-all/#findComment-1201565 Share on other sites More sharing options...
cyberRobot Posted April 14, 2011 Share Posted April 14, 2011 As a side note, according to the mysql_query() function description the query string shouldn't end with a semicolon: http://php.net/manual/en/function.mysql-query.php <?php //OLD CODE $sql= "SELECT * FROM root123 ORDER BY ID;"; //CHANGE TO $sql= "SELECT * FROM root123 ORDER BY ID"; ?> With that said, PHP doesn't seem to throw any errors or warnings for the extra semicolon. I also don't see any errors with mysql_error(). Quote Link to comment https://forums.phpfreaks.com/topic/233700-select-function-not-showing-all/#findComment-1201571 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.