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
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.