Jump to content

making arrays with database data


Rifts

Recommended Posts

Ok so I'm trying to use jpgraph which allows you to make graphs with php (you dont need to know anything about jpgraph to help me)

 

anyway how it works is this line

 

data = array(1,3,4,5);  the numbers here are what the graph plots.

 

 

now i'm trying to figure out a way to place values from my database in there. the problem is the amount of values is constantly changing.

 

I tried a lot of things but nothing is working here is my last try:

$result = mysql_query("SELECT thismonth FROM list");


while ($row = mysql_fetch_array($result))
{
	$data[] = $row[0];
}

$number = count($data);


for ($i = 0; $i < $number; $i++)
	{
		$wtf .=  $data[$i] . ',' ;
	}

 

 

now when i echo $wtf i get values such as 6,3,2,0,1  now i tried this  $data = array($wtf); but it doesnt work any ideas?

Link to comment
https://forums.phpfreaks.com/topic/215895-making-arrays-with-database-data/
Share on other sites

im sorry i think i didnt explain it clearly,  the line data = array(1,3,4,5);  is not dynamic i just wrote that line out. what i actaully need would be like this

 

 

$data - array(databasevalue1, databasevalue2, databasevaule3, etc.)

 

What doesn't work? You haven't shown or stated any actual problems or errors or results (or lack of) in this thread. Based on the information so far, it's likely your query failed due to an error and there is no data at all.

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.