I am writing a code to get numerical data from mysql and then use that data to produce a scatter plot in jpgraphs.
$f2 = "SELECT `COL 11` FROM `TABLE 1` WHERE 1 LIMIT 1,30;";
$result1 = mysql_query($f2) or die("Cannot verify user " . mysql_error());
if(mysql_num_rows($result1)>0)
{
$index1=0;
while($present_row1= mysql_fetch_assoc($result1))
{
$datay[$index1]=(float)$present_row1;
$index1++;
}
}
print_r($datay);
When I typecast as float as the data is decimal values and print_r it I get the following output.
Array ( [0] => 1 [1] => 1 [2] => 1)
But if don't typecast it the numerical values are there but they are in string format and I cannot plot them on graph.
Array ( [0] => Array ( [COL 11] => -22039942 ) [1] => Array ( [COL 11] => -26151110 ) )
$present_row1
is an array, you can't cast it to a float.
Try:
$datay[$index1]=(float)$present_row1["COL 11"];
(This is your $present_row1
: Array ( [COL 11] => -22039942 )
)