Quick and hopefully simple PHP question

Associate
Joined
16 Aug 2004
Posts
268
I am querying a database and need to pull back some values and store them in the into an array so it looks like this:

Code:
$data = array(25,0,7,6,15,4,3,22,1);

This is what I have but it doesn't seem to be pulling the values in:

Code:
$query  = "SELECT * FROM items";
$result = mysql_query($query);
	
while($row = mysql_fetch_array($result, MYSQL_ASSOC))
{
	$data[] = $row['id'];
}

Can anyone point me in the right direction?
 
Thanks for the reply, I tried using your above code but I must not have linked it in correctly as when I print the array I get the following:

Code:
Array ( [0] => [1] => [2] => [3] => [4] => [5] => )

Which means it is querying my database as their are 6 results but it isn't showing them. Any ideas?
 
Thanks for all the help everyone I have manged to get a bit further but am stuck again but it is more to do with Open Flash Charts.

I now have my array but when I'm sending the data over to create the graph my array has quotes around each value:

{"elements":[{"type":"bar_glass","colour":"#BF3B69","text":"Last year","font-size":12,"values":["25","19","15","6","13","11"]}],"title":{"text":"Changes - Last 5 Days"},"y_axis":{"min":0,"max":30,"steps":10}}

When it should look like:

{"elements":[{"type":"bar_glass","colour":"#BF3B69","text":"Last year","font-size":12,"values":[25,19,15,6,13,11]}],"title":{"text":"Changes - Last 5 Days"},"y_axis":{"min":0,"max":30,"steps":10}}

I'm pretty sure that it isn't php causing the problem as that is just the way it outputs an array and you can't really edit it.

EDIT: Fixed! found this if anyone ever has the same problem: http://forums.openflashchart.com/viewtopic.php?f=9&t=1738
 
Last edited:
Back
Top Bottom