Jump to content

php adding and subtracting


meow20

Recommended Posts

Hi ! please help me . im having a trouble with this im actually new to php. 
it says Notice: Undefined index: prev in C:\xampp\htdocs\new\viewbill.php on line 21

Notice: Undefined index: pres in C:\xampp\htdocs\new\viewbill.php on line 22

Notice: Undefined index: price in C:\xampp\htdocs\new\viewbill.php on line 23

Notice: Undefined index: id in C:\xampp\htdocs\new\viewbill.php on line 28

 
<?php
include 'connection.php';
$id = $_GET['id'];
$result = mysql_query("SELECT * FROM meter WHERE reading_id  = '$id'");
 
 
echo "<table border='1' bgcolor='#fff'>
<tr>
<th>Id</th>
<th>Previous Reading</th>
<th>Present Reading</th>
<th>Consuption</th>
<th>Date</th>
<th>Bill Amount</th>
<th>Action</th>
</tr>";
 
while($row = mysql_fetch_array($result)){
 
 $prev=$row['prev'];
 $pres=$row['pres'];
 $price=$row['price'];
 $totalcons=$pres - $prev;
 $bill=$totalcons * $price;
 
  echo "<tr>";
  echo "<td>" . $row['id'] . "</td>";
  echo "<td>" . $prev . "</td>";
  echo "<td>" . $pres . "</td>";
  echo "<td>". $totalcons."</td>";
  echo "<td>" . $price . "</td>";
  echo "<td>" . $bill . "</td>";
  echo "</tr>";
  }
  
echo "</table>";
 
?>
 
Link to comment
https://forums.phpfreaks.com/topic/292887-php-adding-and-subtracting/
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.