homepage Welcome to WebmasterWorld Guest from
register, free tools, login, search, pro membership, help, library, announcements, recent posts, open posts,
Become a Pro Member

Home / Forums Index / Code, Content, and Presentation / PHP Server Side Scripting
Forum Library, Charter, Moderators: coopster & jatar k

PHP Server Side Scripting Forum

I'm losing my first set of records...
PHP / MySQL Dropping one recordset on me. Why?
SEO Speedster

 7:13 pm on Nov 10, 2001 (gmt 0)

Here is the code:

$query = "SELECT * FROM directory WHERE city_service LIKE \"%$form_city%\" ORDER BY last_name";
$result = mysql_query("$query") or die(mysql_error());
$row = mysql_fetch_array($result, MYSQL_ASSOC);

while ($row = mysql_fetch_array($result, MYSQL_ASSOC))

...When it is used, for some reason, it is not displaying the first (or last?) record. For example, if the criteria is filled in where the database has only one row with that value, then it does not output anything at all.

Any ideas on this?

Much thanks,



 10:14 pm on Nov 10, 2001 (gmt 0)

Quick guess (I could be totally wrong).

You need to remove the 1st $row = mysql_fetch_array($result, MYSQL_ASSOC); statement.

That statement gets the 1st row, so, in the case where only one row is returned, the while statement is not executed.

SEO Speedster

 11:13 pm on Nov 10, 2001 (gmt 0)

Thanks Mark, works great!

Global Options:
 top home search open messages active posts  

Home / Forums Index / Code, Content, and Presentation / PHP Server Side Scripting
rss feed

All trademarks and copyrights held by respective owners. Member comments are owned by the poster.
Home ¦ Free Tools ¦ Terms of Service ¦ Privacy Policy ¦ Report Problem ¦ About ¦ Library ¦ Newsletter
WebmasterWorld is a Developer Shed Community owned by Jim Boykin.
© Webmaster World 1996-2014 all rights reserved