I want to select a table from my SQL database. This table can have many different columns, as I'm putting together a dynamic query.
How can I rewrite my fetch_array
to a dynamic number of columns?
Here is my current code:
$q = $db_object->query($query);
$returnstring = '';
while($r = $q->fetch_array()){
$returnstring .= '<tr>';
$returnstring .= '<td>'.$r.'</td>'; //Here can appear many different columns.
$returnstring .= '</tr>';
}
In the query could e.g. two, three, four or more columns of the table show up.
Can I do a foreach
or something like this?