ok well I have written a function that is supposed to take the sql you give it an return an array for you to output. the problem is getting the array becasue the sql is different every time so I get an array of the column names names like so.
for($i=0; $i < mysqli_num_fields($result); $i++)
{
$row = mysqli_fetch_field($result);
$values[] =$row->name;
}
so that puts all the names in an array but what I do next I have no clue usually with my sql I know the row names so I create a while loop to put the values in an array like this
while( $query = mysqli_fetch_array($result))
{
$gather[] = array('id' => $query['id'], 'name' => $query['name']);
$i++;
}
so the problem as you can see is how do I also get the variable names in that array?
if its dynamic.
i want to be able to do something like
for($i=0; $i < mysqli_num_fields($result); $i++)
{
$row = mysqli_fetch_field($result);
$values[] =$row->name;
$values2[] = $query['$row->name'];
}
but you can't just use $query without it being set at a varaible and if it gets set as a variable then it's not just $query anymore so how do go about getting this dynamic array?