Fill mySQL table to PHP matrix
Is there a method to fill from one column of mySQL table to a PHP Matrix (array).
Any help would be much appreciated.
Â
Is there a method to fill from one column of mySQL table to a PHP Matrix (array).
Any help would be much appreciated.
Â
Hi Elias Cooper,
Hope that my message finds you well.
From my experience in PHP I didn’t face this case but I have searched in (stack overflow) site and this may help you.
You can check the following URL:
https://stackoverflow.com/questions/1538229/create-php-array-from-mysql-column
Also you can take a look at the following URL:
https://stackoverflow.com/questions/10668680/php-fill-array-from-multiple-sources
Hope that this will help you.
Thanks,
Â
Â
Yes there is a way to do that. First, create a temporary storage where you will put the data you will be getting from your MySQL table. Say for example you choose $temp.
$temp = mysql_query (‘select * from table’);
Now you have to create another temporary storage for the array and for this, we will be using the same $temp to make a loop.
$temp = array ();
A condition is needed at this point. The condition’s logic should be like this: if you get a result from the query you made in $temp, it should be stored in an array and for each result you get, there is a corresponding array for that. It should look something like this:
While ($a = mysql_fetch_array ($temp)) {
Foreach ($a as $a1=>$b1) {
                  $temp [$a1] = $b1;
         }
         array_push ($temp);
         unset($temp);
}
Â