Jump to content

How to copy data to array of arrays


seniorfisker

Recommended Posts

I have this array that I will use for the SVGGraph chart class


I can easily get it working by setting in data manually in the code like this:


(This is an example from the SVGGraph web)


$values = array(


 array('Dough' => 30, 'Ray' => 50, 'Me' => 40, 'So' => 25, 'Far' => 45, 'Lard' => 35),


 array('Dough' => 20, 'Ray' => 30, 'Me' => 20, 'So' => 15, 'Far' => 25, 'Lard' => 35,


  'Tea' => 45)


);


 


but 


I want to put in the data from 2 MySql functions (one for each chart line)


I have tested the queries with simple arrays so I'm sure that they work


But I can't find out how to copy the values from the MySql result into the arrays


 


if (mysqli_multi_query($link, $query)) 


{


    do 


   


if ($result = mysqli_store_result($link)) 


        {


        while ($row = mysqli_fetch_row($result)) 


        {


        if ($snr==1){


        $values[0][0][$cnt] = '';   // here should the 'dough' type values go


        $values[0][1][$cnt] = $row[0];  // And here the number


        }else{


        $values[1][0][$cnt] = '';


        $values[1][1][$cnt] = $row[0];


        }


        $cnt++;        


        $reccnt=$cnt; 


            }            


            mysqli_free_result($result);


        }


        if (mysqli_more_results($link)) 


        {


           $snr=2;


           $cnt=0;


        }


    } while (mysqli_next_result($link));


}


mysqli_close($link);

Link to comment
https://forums.phpfreaks.com/topic/276061-how-to-copy-data-to-array-of-arrays/
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.