问题在于变量$tot
,$tot
添加并为其他三个变量赋值,即$seone
,$setwo
,$sethree
。
但在某些情况下,其中一个变量没有传递值,因此在页面中放置未定义的变量错误。如果在这些变量中没有传递值,我需要将默认值设为零,我尝试了很多,没有修复。
<BR>
<?php
$result = mysql_query("SELECT count(id) AS total FROM recevd where packages = '110 PER PERSON'");
$values=mysql_fetch_array($result);
$num_two=$values['total'];
echo $num_two.' CUSTOMERS FOR PACKAGE 110 PER PERSON';
?>
<BR>
<?php
$result = mysql_query("SELECT count(id) AS total FROM recevd where packages = '120 PER PERSON'");
$values=mysql_fetch_array($result);
$num_three=$values['total'];
echo $num_three.' CUSTOMERS FOR PACKAGE 120 PER PERSON';
?>
<br>
<br>
DAILY NEEDED QUANTITY FOR
<?php
/*
isset() is used to check wheather arctile id is received through url from "index.php" file and if it is set corresponding arctile is displayted using SELECT statement.
*/
if(isset($_GET['id']))
{
$id=$_GET['id'];
$qry=mysql_query("SELECT * FROM addingre WHERE id=$id", $con);
if(!$qry)
{
die("Query Failed: ". mysql_error());
}
/* Fetching data from the field "title" */
while($row=mysql_fetch_array($qry))
{
$ttt= $row['ingredients'];
}
}
?>
<?php
echo '<h2>'."$ttt".'</h2>';
$hh = '7';
?>
<br>
100 Per Person<br>
<?php
$query_check_credentials = "SELECT product, SUM(quantity) AS total_amount FROM ingredients WHERE item = '$ttt' AND package = '100 PER PERSON' GROUP BY product";
$res = mysql_query($query_check_credentials);
while($row = mysql_fetch_array($res))
{
echo $row['total_amount']*$num_one /'1000'.'(KG/LI)';
$seone = $row['total_amount']*$num_one.'(KG/LI)';
}
?>
<br>
110 Per Person<br>
<?php
$query_check_credentials = "SELECT product, SUM(quantity) AS total_amount FROM ingredients WHERE item = '$ttt' AND package = '110 PER PERSON' GROUP BY product";
$res = mysql_query($query_check_credentials);
while($row = mysql_fetch_array($res))
{
echo $row['total_amount']*$num_two/'1000'.'(KG/LI)';
$setwo = $row['total_amount']*$num_two.'(KG/LI)';
}
?>
<br>
120 Per Person<br>
<?php
$query_check_credentials = "SELECT product, SUM(quantity) AS total_amount FROM ingredients WHERE item = '$ttt' AND package = '120 PER PERSON' GROUP BY product";
$res = mysql_query($query_check_credentials);
while($row = mysql_fetch_array($res))
{
echo $row['total_amount']*$num_three/'1000'.'(KG/LI)';
$sethree = $row['total_amount']*$num_three.'(KG/LI)';
}
?>
<br>
<h3>TOTAL QUANTITY NEEDED FOR THE DAY <?php
echo $time_now;
?> =
<?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))
{
$tot = $seone+$setwo+$sethree;
echo $tot/1000 .'(KG/LI)';
}
?>
</h3>
<br>
Weekly Needed Quanity
<br><br>
100 Per Person<br>
<?php
$query_check_credentials = "SELECT product, SUM(quantity) AS total_amount FROM ingredients WHERE item = '$ttt' AND package = '100 PER PERSON' GROUP BY product";
$res = mysql_query($query_check_credentials);
while($row = mysql_fetch_array($res))
{
echo $row['total_amount']*$num_one*$hh/'1000'.'(KG/LI)';
}
?>
<br>
110 Per Person<br>
<?php
$query_check_credentials = "SELECT product, SUM(quantity) AS total_amount FROM ingredients WHERE item = '$ttt' AND package = '110 PER PERSON' GROUP BY product";
$res = mysql_query($query_check_credentials);
while($row = mysql_fetch_array($res))
{
echo $row['total_amount']*$num_two*$hh/'1000'.'(KG/LI)';
}
?>
<br>
120 Per Person<br>
<?php
$query_check_credentials = "SELECT product, SUM(quantity) AS total_amount FROM ingredients WHERE item = '$ttt' AND package = '120 PER PERSON' GROUP BY product";
$res = mysql_query($query_check_credentials);
while($row = mysql_fetch_array($res))
{
echo $row['total_amount']*$num_three*$hh/'1000'.'(KG/LI)';
}
?>
<h3><h3>TOTAL QUANTITY NEEDED FOR THE NEXT 7 days <?php
echo $time_now;
?> -to- <?php echo $time_end ?> =
<?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))
{
$tot = $seone*$hh+$setwo*$hh+$sethree*$hh;
echo $tot/1000 .'(KG/LI)';
}
?>