Jump to content

How to copy data to array of arrays


seniorfisker
Go to solution Solved by 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
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.