php - calculate average rating from mysql and show it as a graph -


please me solve this. in learning phase of php/mysql.

i have php feedback form rating system 1-5. can find form here http://innovatrix.co.in/feedback_priyajit/feedback%20form1.html

every time user provide feedback saves form values mysql database. below database structure.

enter image description here

now want calculate average data of every row (like waiting) , show on php file graph , separate graph every option on same page.

i know can use query select avg(waiting) feedback average of "waiting"

but how can every options same file , show graph. database updated frequently, should reflect graph also.

please me concept achieving this.

below php file using store form values database.

<title>process</title> <?php $host="localhost"; $user_name="pramir_feedback"; $pwd="feedback"; $database_name="pramir_feedback"; $db=mysql_connect($host, $user_name, $pwd); if (mysql_error() > "") print mysql_error() . "<br>"; mysql_select_db($database_name, $db); if (mysql_error() > "") print mysql_error() . "<br>"; $waiting = $_post['radio1']; $consultation = $_post['radio2']; $preoperative = $_post['radio3']; $specialists = $_post['radio4']; $assistants = $_post['radio5']; $painful = $_post['radio6']; $operatingroom = $_post['radio7']; $thought = $_post['radio8']; $recommend = $_post['radio9']; $suggestions = $_post['suggestions']; $query = "insert feedback (waiting, consultation, preoperative, specialists, assistants, painful, operatingroom, thought, recommend, suggestions) values ('" . $waiting . "', '" . $consultation . "', '" . $preoperative . "', '" . $specialists . "', '" . $assistants . "', '" . $painful . "', '" . $operatingroom . "', '" . $thought . "', '" . $recommend . "', '" . $suggestions . "')"; if (mysql_error() > "") print mysql_error() . "<br>"; $qresult = mysql_query($query); echo "<h1>thank submitting details!</h1>"; ?>   

if want averages in 1 query, can delimit them commas.

select avg(waiting), avg(consultation), avg(preoperative), avg(specialists), ...... feedback 

if want know how put them in graph, take @ 1 of many jquery graph or plot makers, like: http://www.jqplot.com/tests/bar-charts.php


Comments

Popular posts from this blog

c++ - Creating new partition disk winapi -

Android Prevent Bluetooth Pairing Dialog -

php - joomla get content in onBeforeCompileHead function -