Peterson Posted November 4, 2007 Share Posted November 4, 2007 Hello. Thanx for look. This is for me unbelievable... I want display all names beginning with letter "A" (There is 9 names beginning with A in my database) - when I run SQL query on server, it show proper list of names - 9 SELECT name FROM database WHERE name LIKE 'A%' - when I check mysql_fetch_row() from my php code, if shows real number - 9 BUT!!! when I run this code, it shows only 8 names and does not show the first one. $result = mysql_query("SELECT name FROM database WHERE name LIKE 'A%' "); $row = mysql_fetch_row($result); echo mysql_num_rows($result)."<br>"; // Shows number 9 WHILE ($row = mysql_fetch_row($result)) { echo $row[0]."<br>"; } // List only 8 names and does not list the first one Please, what's wrong? I found this simple code recommended in all examples on the internet... Quote Link to comment Share on other sites More sharing options...
bwochinski Posted November 4, 2007 Share Posted November 4, 2007 Basically the issue is you're skipping the first row. You call "$row = mysql_fetch_row($result);" right after the query, then again in the while loop before anything is output. Just take out that first mysql_fetch_row line. Quote Link to comment Share on other sites More sharing options...
Peterson Posted November 4, 2007 Author Share Posted November 4, 2007 Thank you very much, now I understand it very well Quote Link to comment 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.