Associate
- Joined
- 1 May 2006
- Posts
- 810
- Location
- Bristol, UK
Evening all,
Doing a little bit of a re-code of my site now that I've learnt a bit more PHP and I'm a bit stumped.
I've previously used do/while loops to output the results of mysql queries. Example:
The above has worked well. However, a couple of months back I caught wind that do/while loops were bad practice and bad things happen when the query returns nil result. Based on that I've now tried the following:
As I'm sure the PHP guru's will already know, this example misses the first row returned by $query. How do I overcome this annoying problem? Or is there a better way to display the results of mysql queries?
Cheers in advance,
Freakish_05
Doing a little bit of a re-code of my site now that I've learnt a bit more PHP and I'm a bit stumped.
I've previously used do/while loops to output the results of mysql queries. Example:
Code:
do {
echo $queryrow['name'];
}
while ($queryrow = mysql_fetch_assoc($query))
Code:
while ($queryrow = mysql_fetch_assoc($query))
{
echo $queryrow['name'];
}
Cheers in advance,
Freakish_05