I am struggling to store the sql fetched results in an array. I tried alot of suggested methods I found on the internet and I cant get it to work. I am obviously doing something wrong. This is the latest code I am testing atm:
// The following code is place after prepare() and mysqli_stmt_execute($stmt)
mysqli_stmt_bind_result($stmt, $colDescription);
$descArray = array();
$i = 0;
/* fetch values and store them to each variables */
while (mysqli_stmt_fetch($stmt)) {
$fetch = $colDescription;
$descArray[$i] = $fetch;
$i++;
}
//For testing to see what echos in that array
foreach($descArray as $v) {
echo $v;
}
In the above code, when I echo the array, only the last row of the table is outputted. So I think I am basically overlapping the values to the last row and its not really storing all the fetched values in an array. What am I doing wrong here? Can someone guide me please?