Jump to content

Modifying incoming SQL data into array?


gibbonuk

Recommended Posts

Hi, just getting myself a little confused with somthing.

 

I have the simple method of retrieving data from a mysql into an array, but as the values come i want to turn them into a percentage just before they go into the array, where can i do the calculation?

 

The code for fetching the mysql data into array is:

 

$request = "SELECT * FROM $table WHERE id BETWEEN $start_range AND $end_range";
	$result = mysql_query($request) or die("Cannot get sql data");
		$id=""; $value="";
			while($row = mysql_fetch_array($result)){

				//gather data from sql
			//$id[] = $row["id"];
			$value[] = $row["value"];
		} 
	//save data into arrays
	$myData->addPoints($value,$table);
	$myData->setSerieDescription($table,"DataSet ".$i);

 

can i just do the calculation here : $value[] = $row["value"]; ????

 

Thanks

 

Link to comment
Share on other sites

What are they a percentage of?

 

You can certainly do it the way you have stated.

 

$value[] = "do calculation on" $row["value"];

 

This would create an array called $value containing all th %values in the same order as they were originally written int o th $row['value'] array

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.