Okay, so I realize that when do:
//connection code;
//query code;
//$result= mysqli_query();
$row= mysqli_fetch_array($result);
you create an associative array where the column names from your table are the keys for the data in the respective row.
Then you can use:
while ($row= mysqli_fetch_array($result))
{
//code to echo out table data.
}
My question is how does the while loop go to the next row after each iteration? I thought that was what foreach loops were for?
PDOStatementsupports theTraversableinterface, so it can be used inforeachloops directly, unlike mysqli results.mysqli_queryreturnmysql_resultobject which is Traversable so usingforeachwill work too.