Whenever I see PHP code that selects a single row from the database they just use LIMIT 1 in the query and still use a WHILE loop to select the data, theres got to be a more efficient way? (i.e. without the loop)
Another way (any of the row fetching functions will do):
Code:
$row = mysql_fetch_assoc($result);
A thought:
Ideally fetching a single row should always cover all bases of possible errors:
- no result
- more than one result
With LIMIT 1 you'll never find out if there are duplicates (unless it's a unique key).
This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
By continuing to use this site, you are consenting to our use of cookies.