|
The article mentions that you can use the foreach construct to make your code for dumping database query results more readable. Thus:
foreach ($row as $field) echo "<td>$field</td>";
However, if you don't set the result_type parameter of mysql_fetch_array(), this doesn't work properly: each field is accessed and printed twice. I think this is because it goes through each $row element, as numerically indexed, and also as associatively indexed.
To get this to work, set the result_type parameter, like so:
while ($row = mysql_fetch_array($query_result, MYSQL_ASSOC))
Otherwise, the article and the associated book are very good, highly recommended! (at least for newbies like me)
|