Welcome to WebmasterWorld Guest from

Forum Moderators: coopster & jatar k

Message Too Old, No Replies

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)

10+ Year Member

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!

Featured Threads

Hot Threads This Week

Hot Threads This Month