Heheh, yes PHP is probably the most complicated language I've ever used. The, um, quirks I'll call them (ie: inconsistencies
) are quite nonsensical. I will give it that its extremely easy to learn basic PHP, but if its your first language than it will teach really bad habits.
So things like mysql_fetch_* returning false is perfectly fine for the basic PHP level. Null = false = 0 = '0' = '' = array(), so with the weak datatypes it actually works alright (MySQLi fixes this btw, and returns null when no more records are present). Problem is more into the OO approach for things where testing for null is common place. Unlike the procedural PHP where null is rarely used for any type of condition.
It is frustrating though. Only in PHP do you actually need to use === to see if a 'string' contains 's'. Lol. Even perl returns -1 on no match.
Oh and for the for loop, yeah there is nothing wrong with that. You could also use a while to do both:
while (++$i && $row = mysql_fetch_assoc($qry))
. Note that if you start $i at 0 (which is what I'd do if I wanted 1 as the first record), and you don't provide a condition for the increment like above, using $i++ won't work of course since its evaluated as 0, which would terminate the loop.
Ahh, good fun.