You need to add to the array, not just rewrite it:
$r_refcats = mysqli_query($global_dbh,"select distinct(cat) from reference");
while(($row = mysqli_fetch_array($r_refcats)) != false) {
${$row[0]}=array();
}
$r_references = mysqli_query($global_dbh,"select cat,id,description from reference");
while(($row = mysqli_fetch_array($r_references)) != false) {
${$row[0]}[] = $row;
}
Also, I think you just want to use $row
as your array, not an array of $row
. In other words, I think you want to have the data be the data in $row
, not array(0=>$row)
-- hence my edit to the last line.