html and java script for bar chart with data from data base

520 Views Asked by At

I'd like to get my current table presentation of data called from MySQL data base tables, to look better, as a bar chart or pie chart. I'm on Dreamweaver CS5.5 and don't have CF. I'd prefer to write it into the current page (shown below) in HTML and JavaScript. Does anyone have any ideas please? My current page is attached. Thanks, Rose

<title>Results4</title>

</head>
<body>

<form action="resultsparta4.php" method="post">
<script>
function myFunction()
{
window.print();
 }
</script>
<?
$client_id =$_POST['clientid'];

print "<table border=5 align= \"center\" width=\"75%\"  >";
print "<tr><td><h2>Results page 4: Your results are ranked below </h2></b></p> </td></tr>";

// access the apache web server

 $host = "localhost";
 $user = "root";
 $pwd = "";

 $connect = mysql_connect($host,$user,$pwd);

 // set up the database variable

 $db = "clients";

 //set up the select query

 $query = "SELECT a.client_id, a.percent, b.percent, c.percent, d.percent
 FROM apples a, oranges b, pears c,
grapefruit d
WHERE a.client_id = b.client_id 
AND b.client_id = c.client_id 
AND c.client_id = d.client_id
ORDER BY client_id DESC";

// connect to a database and create a query

$result = mysql_db_query($db,$query);
$row = mysql_fetch_array($result);
$list=array();

$a = $row[1]; 
$b = $row[2];
$c = $row[3];
$d = $row[4];

$list = array('apples %'=>$a,
'oranges %'=>$b,'pears %'=>$c,'grapefruit %'=>$d);
print "<table border=5 align= \"center\" width=\"75%\"  bgcolor=\"BD9DFF\">";
print "<tr><td><h2>Section </h2></td><td><h2>Percent 
</h2></td></tr>";
arsort($list);
foreach ($list as $key => $val)

{ 
//set up the table and headings
print "<tr><td><h2>$key</h2></td><td><h2>$val</h2></td></tr>";
} 

//close the table
print "</table>";

?>
<?
$client_id =$_POST['clientid'];

print "<table border=5 align= \"center\" width=\"75%\"  >";
?>
print "<table border=5 align= \"center\" width=\"75%\"  bgcolor=\"BD9DFF\">";
print "<tr><td><h2>Section </h2></td><td><h2>Percent</h2></td></tr>";
?>
</body>
</html>
0

There are 0 best solutions below