Jump to content

Recommended Posts

Hey everyone, I've sweated over this last night and hope somebody could help me out.

 

First, A result array I'd want to get could look like this:

 

$chart['chart_data'] = array ( 
array ( "Region A", 10,12,11,15,20,22,21,25,31,32,),
);

 

The first is "Region A" and the rest is just int's that I'd pull from the db, so to set it I'd do this:

 

$chart [ 'chart_data' ][ 0 ][ 0 ] = "Region A";

 

But the problem is when I want to insert the data in the while loop (like the 10,12,11,15...), I've tried array_push but it's not working, maybe it doesn't work with multi-dimensional arrays? Anyways, here.'s what I tried, the following inside the "while" to loop the mysql results with mysql_fetch_assoc:

 

while($r=mysql_fetch_assoc($res)) {
    
     $chart [ 'chart_data' ][ 0 ][ 0 ] = array_push($chart['chart_data'][0][0], $r['wght']);
     // the above line is where I have problems    ^^
}

 

What I want is on each loop to insert the fetched data inside the array so that it gives what I gave first at the top, but what I've written above doesn't work, it gives me a warning saying "first argument must be an array" which seems to be one, but anyway, anybody know how to do this?

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.