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
https://forums.phpfreaks.com/topic/243102-modifying-incoming-sql-data-into-array/
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

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.