переменные, передающие ничего, показывают неопределенную ошибку переменной, поэтому вы хотите поместить значение по умолчанию для переменной

Проблема заключается в переменной $tot , $tot add и присваивании значения для трех других переменных, то есть $seone , $setwo , $sethree . но в некоторых случаях ни одна из переменных не имела в ней значения, так что на странице выводится ошибка неопределенной переменной. Мне нужно поставить значение по умолчанию 0, если в этих переменных нет значения, я много пробовал, не исправил.

 <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.'&nbsp;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.'&nbsp;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)'; } ?> в <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.'&nbsp;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.'&nbsp;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)'; } ?>