用于条形图的html和javascript以及来自数据库的数据

时间:2014-07-05 08:18:25

标签: javascript html mysql

我想从MySQL数据库表中获取当前表格的数据表示,以条形图或饼图的形式更好看。我在Dreamweaver CS5.5上,没有CF.我更喜欢用HTML和JavaScript将它写入当前页面(如下所示)。有没有人有任何想法吗?我当前的页面已附上。谢谢,罗斯

<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 个答案:

没有答案