Fill mySQL table to PHP matrix

Asked By 30 points N/A Posted on -

Is there a method to fill from one column of mySQL table to a PHP Matrix (array).

Any help would be much appreciated.


Best Answer by Luker Malcom
Answered By 0 points N/A #147276

Fill mySQL table to PHP matrix


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:

Also you can take a look at the following URL:

Hope that this will help you.



Best Answer
Best Answer
Answered By 5 points N/A #147277

Fill mySQL table to PHP matrix



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);




Related Questions