Hoping someone can help me out with this one - this being my first time with OOP. I am trying to create a list of records from a mysql database and populate a table with the returned results. I am able to connect and pull back the first record, but none of the records after that. I'm sure that this is something really simple, but I'm just not seeing it. There are three files I'm using - DB.php to do all the database connection stuff, ListRecords.php to build the table and a test.php to display the results. The problem is in the buildTable method in the ListRecords.php file:
// Build the table containing the data
function buildTable($num_fields, $field_name, $db) {
$count = 0;
while($query_data = $db->fetchAssoc()) {
echo "<tr>\n";
while($count < $num_fields) {
$field_name[$count] = $query_data["$field_name[$count]"];
echo "<td align=\"center\">$field_name[$count]</td>\n";
$count++;
}
echo "</tr>\n";
}
}
Thanks in advance for any help.