Im trying to create a database array and have the results put into a graph.
However the coding ive written is only giving one result.
its below
<?
$week = $_GET['week'];
$users_id= $_GET['users_id'];
include 'config.php';
$db = mysql_connect($db_host,$db_user,$db_pass);
mysql_select_db ($db_name) or die ("Cannot connect to database");
$result = mysql_query("SELECT * FROM weekly WHERE users_id = '$users_id' LIMIT 10");
while($r=mysql_fetch_array($result))
{
$id=$r["id"];
$device_id=$r["users_id"];
$week=$r["week"];
$percent_week=$r["percent_week"];
$user_array = array ("$percent_week");
foreach ( $user_array as $key=>$val ){
$val_me = ($val*2.5);
$graphValues = array ("$val_me");
// Define .PNG image
header("Content-type: image/png");
$imgWidth=200;
$imgHeight=200;
// Create image and define colors
$image=imagecreate($imgWidth, $imgHeight);
$colorWhite=imagecolorallocate($image, 255, 255, 255);
$colorGrey=imagecolorallocate($image, 192, 192, 192);
$colorBlue=imagecolorallocate($image, 0, 0, 255);
// Create border around image
imageline($image, 0, 0, 0, 250, $colorGrey);
imageline($image, 0, 0, 250, 0, $colorGrey);
imageline($image, 249, 0, 249, 249, $colorGrey);
imageline($image, 0, 249, 249, 249, $colorGrey);
// Create grid
for ($i=1; $i<11; $i++){
imageline($image, $i*25, 0, $i*25, 250, $colorGrey);
imageline($image, 0, $i*25, 250, $i*25, $colorGrey);
}
// Create line graph
for ($i=0; $i<10; $i++){
imageline($image, $i*25, (250-$graphValues[$i]), ($i+1)*25, (250-$graphValues[$i+1]), $colorBlue);
}
// Output graph and clear image from memory
imagepng($image);
imagedestroy($image);
}}
?>
Can anyone see why from my coding?
David