'PHP array filled by a MySQL query [closed]
I need to fill multiple different arrays by using a MySQL query. This would have up to 16 different arrays. I want to specify each array with a number at the end. so $resultmm17, $resultmm18, and so on. I want to do this with a for loop. If I try to do a var_dump($resultmm17), I get an HTTP 500 error on the current code.
$indexval = 1;
for ($i = 0; $i < $row[4]; $i++) {
$aa = 17;
$fannn = "SFan".$indexval;
$query12 = "SELECT * FROM vibrationinfo2
WHERE unitserial = '$serial'
AND component = '$fannn' ORDER BY value2 DESC";
$result12 = mysqli_query($link, $query12);
${'resultsmm'.$aa} = array();
${'hertzcalculated'.$aa} = array();
while ($row12 = mysqli_fetch_assoc($result12)) {
${'resultsmm'.$aa}[] = $row12['value3'];
${'hertzcalculated'.$aa}[] = $row12['value2'];
}
$indexval++;
$aa++;
}
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|
