It seems that you don't understand why mysql_fetch_array is most often used inside a loop. The loop is not required! if you don't put mysql_fetch_array inside a loop, you can only get the first row and that's it, because calling mysql_fetch_array will return the next row in your result. if you expect more than one row, you have to call mysql_fetch_array for as many times as you expect rows. This could be done by calling mysql_fetch_array manually for as many times you need or via some sort of loop. The easiest way to get all rows, although you don't know how many rows you'll get, is using a while loop.
"Brian Drexler" <[EMAIL PROTECTED]> schrieb im Newsbeitrag [EMAIL PROTECTED]">news:[EMAIL PROTECTED]... > Here is my code: > > mysql_connect("localhost","username","password"); > $result=mysql_db_query("Database","select * from table_name where > criteria=whatever limit 1"); > while($r=mysql_fetch_array($result) { > $Value1=$r["TableFieldName1"]; > $Value2=$r["TableFieldName2"]; > echo "$Value1, $Value2"; > } > > My question is this....is the while statement needed when I'm only returning > one record? > > Brian > -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php