| | |
Need to Sum up this code
Please support our PHP advertiser: PostgreSQL or MySQL? Compare and contrast the two most popular open source databases
![]() |
•
•
Join Date: Mar 2007
Posts: 13
Reputation:
Solved Threads: 0
Here is my code I need help with:
It outputs like this:
Class: SEARCHES 102
Price: 300.01
Class: FIREARMS 102
Price: 200.02
Total Price of Classes for employee 1006 :
Employee Queried
Close
What I want to do is add up the Prices and put it after the : part can anyone help me? This is for my info647 class.
mysql_connect($host,$username,$password); @mysql_select_db($database) or die( "Unable to select database"); $query = "SELECT DISTINCT info647_crse . crsdesc , info647_crse . crsprice FROM info647_emp JOIN info647_reg USING ( empno ) JOIN info647_off USING ( offerno ) JOIN info647_crse USING ( crsno ) WHERE empno = '$empno' LIMIT 0, 30 "; $result=mysql_query($query); $num=mysql_numrows($result); mysql_close(); echo "<b><center>Database Output</center></b><br><br>"; $i=0; while ($i < $num) { $desc=mysql_result($result,$i,"crsdesc"); $crsprice=mysql_result($result,$i,"crsprice"); echo "<br>Class: $desc<br>Price: $crsprice<br><br><hr><br>"; $i++; } echo("Total Price of Classes for employee $empno :"); echo("<p align='center'><font face='Arial' size='3' color='#FF0000'>Employee Queried</font></p>"); include("footer.html"); ?>
It outputs like this:
Class: SEARCHES 102
Price: 300.01
Class: FIREARMS 102
Price: 200.02
Total Price of Classes for employee 1006 :
Employee Queried
Close
What I want to do is add up the Prices and put it after the : part can anyone help me? This is for my info647 class.
•
•
Join Date: Mar 2007
Posts: 13
Reputation:
Solved Threads: 0
I am not sure I understand where to put that in the code. This is what I did and it didn't work. Thank you in advance for the help.
while ($i < $num) { $desc=mysql_result($result,$i,"crsdesc"); $crsprice=mysql_result($result,$i,"crsprice"); echo "<br>Class: $desc<br>Price: $crsprice<br><br><hr><br>"; $i++; } $crsprice1=$crsprice1+$crsprice echo("Total Price of Classes for employee# $empno "); echo ("$crsprice1"); echo("<p align='center'><font face='Arial' size='3' color='#FF0000'>Employee Queried</font></p>"); include("footer.html"); ?>
![]() |
Similar Threads
- need help, need to generate 10 random numbers, such that their sum is less than 1 (C)
- what is C++ builder code for sum (C++)
- I just need help starting this program please (C++)
- transfer input.txt to output.txt help prz (C++)
- This is an easy one (C++)
- Cubing Digits Individually (C++)
- conversion type (C++)
- Im new to this site and c++ (C++)
Other Threads in the PHP Forum
- Previous Thread: Help (again) on a modify record script
- Next Thread: Symfony + skipping actions
| Thread Tools | Search this Thread |
301 apache api array autosuggest beginner beneath binary broadband broken button cakephp checkbox class cms code compression countingeverycharactersfromastring crack cron curl database date decode display dynamic echo email error file files folder form forms function functions google href htaccess html httppost image include insert integration ip javascript joomla limit link links login mail match md5 menu mlm multiple mysql mysql_real_escape_string oop paypal pdf php problem protocol query radio random recursion remote script search searchbox server session sessions sms smtp source space sql strip_tags survey syntax system table tutorial undefined update upload url validator variable video virus votedown web window.onbeforeunload=closeme; youtube





