MrTV
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
thank
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
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
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
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.
What you're prety much looking for though is:
<?php
$total = 0;
$db = mysql_connect("localhost",
mysql_select_db("mydb",$db
$result = mysql_query("SELECT extendedcost FROM orders",$db);
while ($row = mysql_fetch_array($result,
$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.
JP