Link to home
Start Free TrialLog in
Avatar of MrTV
MrTVFlag for Thailand

asked on

how to write php to get total bill

please suggest me how to write program form php to get to totlal Bill please show me code
thank

ASKER CERTIFIED SOLUTION
Avatar of rweston
rweston
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Give some details of the type of problem you are trying to solve... are you writing a shopping basket system, or an accounting system, or do you just want add up some numbers?

JP
Avatar of MrTV

ASKER

How can I use  PHP to get data form my sql Many tables and then  sum it Please give me a sample code
SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Like jdpipe mentioned, some reading (esp. from the link is provided would help) and using the php manual as well would get you a solution.

What you're prety much looking for though is:

<?php
$total = 0;

$db = mysql_connect("localhost", "root");
mysql_select_db("mydb",$db);  //  replace mydb with the name of the database you want to use

$result = mysql_query("SELECT extendedcost  FROM orders",$db);

while ($row = mysql_fetch_array($result, MYSQL_ASSOC)) {
   $total += $row["extendedcost"];
}

mysql_free_result($result);

From multiple tables, you could continue using the 'total' variable, run the same query against the other tables and just continue adding to total.