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

Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Your question is very unclear.

If you were taking in a set of values though using a Form for example with fields, you could have page 1.htm:

<title>Untitled Document</title>

<form name="form1" method="post" action="total.php">
    <input type="text" name="textfield">
    <input type="text" name="textfield2">
  <p>    <input type="text" name="textfield3">
  <p>    <input type="text" name="textfield4">
  <p>    <input type="text" name="textfield5">
    <input type="submit" name="Submit" value="Submit">

total.php would contain:

$total = 0;

foreach($_POST as $var => $value){

$total += $value;


echo $total;


Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day 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?

teeraAuthor Commented:
How can I use  PHP to get data form my sql Many tables and then  sum it Please give me a sample code
Teera it seems like you should probably go and do some basic reading. Please take a look at this introductory tutorial from WebMonkey - I found that site really useful when I was getting started:

If you get through that then come back and ask a more focussed question, with exactly what you want to do, and for what purpose. Give an example of what you want it to look like, etc etc.
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:

$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"];


From multiple tables, you could continue using the 'total' variable, run the same query against the other tables and just continue adding to total.
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today

From novice to tech pro — start learning today.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.