acm2011
05-26-2011, 07:08 PM
Hi, so I have been trying to come up with a way to do a mysql query and store the results so that I can then access them and create an html table.
Here is the code for the query and array:
$query = "SELECT * FROM table WHERE user_id = '" . $_SESSION['user_id'] . "'";
$data = mysqli_query($dbc, $query);
$array = array();
while ($row = mysqli_fetch_array($data)) {
array_push($array, $arr = array ($a => $row['a'], $b => $row['b'], $c => $row['c], $d => $row['d'], $e => $row['e], $f => $row['f']));
}
This should create a large array of arrays, depending on how many rows of data result from the query.
Can someone help me with the code that will now take these arrays and create an html table with the results? Also needs to make sure if there are no results, nothing is produced.
Here is the code for the query and array:
$query = "SELECT * FROM table WHERE user_id = '" . $_SESSION['user_id'] . "'";
$data = mysqli_query($dbc, $query);
$array = array();
while ($row = mysqli_fetch_array($data)) {
array_push($array, $arr = array ($a => $row['a'], $b => $row['b'], $c => $row['c], $d => $row['d'], $e => $row['e], $f => $row['f']));
}
This should create a large array of arrays, depending on how many rows of data result from the query.
Can someone help me with the code that will now take these arrays and create an html table with the results? Also needs to make sure if there are no results, nothing is produced.