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
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.)

 

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.