I have a database such as:
Name, Product, Score, Feedback
Each row (with Dave being the first insert and Sam as the last) for example is:
Dave, Apple, 3, Good
Jim, Pear, 5, Awesome
Sam, Peach, 2, Okay
When I run my code, it would only add Dave's and Jim's to total 8. It's not adding Sam's score value until another new insert has executed.
<?php
//connect to the database
$connectionstring = mysql_connect('localhost', 'teammystic', 'teammystic1' ) or die('Could not connect: ' . mysql_error());
//select the database
mysql_select_db('my_teammystic') or die('Could not select database: ' . mysql_error());
$Query = "SELECT SUM(SCORE) AS VAL FROM customerFeedback";
//execute query
$queryexe = mysql_query($Query) or die('Could not query database: ' . mysql_error());
$dataArray = mysql_fetch_assoc($queryexe);
// Free resultset
mysql_free_result($queryexe) or die('Could not free result: ' . mysql_error());
//disconnect from database
mysql_close($connectionstring) or die('Could not close database: ' . mysql_error());
?>
I am trying to a make an average score display, any help is very appreciated thank you.