I am trying to calculate sales of items using some data to get the total from a SQL database using its id to identify each sale and then display it on the screen. for further use.
<?php
$dbhost = 'localhost:3306';
$dbuser = 'root';
$dbpass = 'mysql';
$conn = mysql_connect($dbhost, $dbuser, $dbpass);
if (! $conn ) {
die('Could not connect: ' . mysql_error());
}
$sql = "select item_num * price + tp AS total from buyers where
Ref_code = '" . $result16['ref_code'] . "' ";
mysql_select_db('sales');
$retval1 = mysql_query($sql, $conn);
if (!$retval1) {
die('Could not get data: ' . mysql_error());
}
$result15 = mysql_fetch_assoc($retval1);
?>
<?php echo $result15['total']; ?> '
I expect it to display the total of each sale as I passed the id to the Query but it is not display anything.