This is a discussion on php question within the Coding Help forums, part of the Webmaster Help category; i am learning php at the moment and when i go to show a recordset if i have five records ...
| |||||||
| Register | Forum Rules | FAQ | Donate | Members List | Calendar | Search | Today's Posts | Mark Forums Read |
| ||||
| i am learning php at the moment and when i go to show a recordset if i have five records in it - but it is only showing four and if add a sixth it only shows up five - why here is the code <?php mysql_connect("localhost", "emerald", "emerald247") or die(mysql_error()); mysql_select_db("emerald_db1") or die(mysql_error()); $query = ("SELECT * FROM names"); $result = mysql_query($query) or die(mysql_error()); $row = mysql_fetch_array($result); while($row = mysql_fetch_array($result)) { echo $row['name']. " - ". $row['surname']; echo "<br />"; } any help thanks |
| |||||
| try this: PHP Code: |
| |||||
| $row = mysql_fetch_array($result); while($row = mysql_fetch_array($result)) You've already pulled one row out ... then you start into your while loop and you're pulling the second ... so get rid of your first $row = mysql_fetch_array($result); |
| Tags |
| php, question |
| Thread Tools | |
| Display Modes | |
|
|
| ||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| PHP includes - correct formatting | EdenWeb | Coding Help | 6 | 16-08-2007 12:02 AM |
| HELP :: PHP regular expression question | littleBird | Coding Help | 3 | 13-03-2007 10:33 PM |
| WTF - Some PHP Obfuscation. | daviddoran | General Chat | 8 | 20-02-2007 05:45 PM |
| Bandwidth question | JamesA | Webmaster Discussion | 4 | 28-01-2007 10:56 AM |
| PHP on windows | louie | Coding Help | 20 | 22-02-2006 06:25 PM |
| ||||||||
| | ![]() | |||||||