Hello, I’m having trouble deciphering what is going on in the following code:
$query = "SELECT * FROM `tbl_users`";
$result = mysql_query($query) or die('Query failed: ' . mysql_error());
while ($line = mysql_fetch_array($result, MYSQL_ASSOC)) {
echo " <tr>
";
echo "<td>$line</td>";
foreach ($line as $col_value) { // $line is an array
echo " <td>$col_value</td>
";
}
echo " </tr>
";
}
I know what the inner foreach() loop is doing but I don’t see how the while() loops works. How is “$line = mysql_fetch_array($result, MYSQL_ASSOC)” a condition? Wouldn’t it return the same value everytime if at all?
And another small question, when entering queries, is it necessary to suround the name of the table with the little tick marks (`) like in the first line? Or can I use single/double/no quotes?
Thanks a bunch. :azn: