for eg: I had 3 values in table item:
car <br>
bike<br>
cycle<br>
In product page when clicking on any product it will pass value to next page and store it as variable, I want to find the sum of item that passed from another page
the code is here.
<?php
if(isset($_GET['id'])){
$id = $_GET['id'];
$qry=mysql_query("SELECT * FROM addingre WHERE id=$id", $con);
if(!$qry){
die("Query Failed: ". mysql_error());
}
while($row=mysql_fetch_array($qry)){
$ttt= "<h2>".$row['ingredients']."</h2>";
}
}
?>
<?php
echo "$ttt";
?>
<?php
$query_check_credentials = "SELECT product, SUM(quantity) AS total_amount FROM ingredients WHERE item = '$ttt' GROUP BY product";
$res = mysql_query($query_check_credentials);
while($row = mysql_fetch_array($res)){
echo $row['total_amount'];
}
?>
bike
– mickmackusa Feb 18 '17 at 17:13