Something like <?
$db = mysql_connect("localhost","database_user","password"); mysql_select_db (database_name); $query = "SELECT * FROM table_name"; $result = mysql_query($query); echo "Computers | Department | Price Per PC | Total Amount<br>"; while ($row = mysql_fetch_row($result)){ $subtotal=$row[0]*$row[2]; $total+=$subtotal; echo "$row[0] | $row[1] | $row[2] | $subtotal<BR>"; $comptotal+=$row[0];} } echo "$comptotal $total"; ?> Obviously format it into a table would make sense, e.t.c. Adam ----- Original Message ----- From: "delz" <[EMAIL PROTECTED]> To: <[EMAIL PROTECTED]> Sent: Thursday, April 11, 2002 5:29 AM Subject: Math Computations > Hi, > > I have this table that looks like this > > Computers | Department | Price per PC | TotalAmount | > 15 | Marketing | $500.00 | | > 5 | Purchasing | $ 300.00 | | > > I want this table to display the total price wherein Computer * Price Per PC > = TotalAmount > and want to display the total no. of computer and the OverAll TotalAmount. > > I want the output to look like this > > Computers | Department | Price per PC | TotalAmount | > 15 | Marketing | $500.00 | $ 7500.00 | > 5 | Purchasing | $ 300.00 | $ 900.00 | > --------- ----------- > 20 $ 8400.00 > > Can anyone help me how to do this in mysql or php. I will surely appreciate > any help I > can get. > > Thanks. > > Delz > > > --------------------------------------------------------------------- > Before posting, please check: > http://www.mysql.com/manual.php (the manual) > http://lists.mysql.com/ (the list archive) > > To request this thread, e-mail <[EMAIL PROTECTED]> > To unsubscribe, e-mail <[EMAIL PROTECTED]> > Trouble unsubscribing? Try: http://lists.mysql.com/php/unsubscribe.php > > > --------------------------------------------------------------------- Before posting, please check: http://www.mysql.com/manual.php (the manual) http://lists.mysql.com/ (the list archive) To request this thread, e-mail <[EMAIL PROTECTED]> To unsubscribe, e-mail <[EMAIL PROTECTED]> Trouble unsubscribing? Try: http://lists.mysql.com/php/unsubscribe.php