Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

how do i calculate a new value from 2 columns whilst looping a table 1

Status
Not open for further replies.

pushyr

Programmer
Jul 2, 2007
159
GB
I have a single table and i would like to calculate two columns (imp and clicks) while looping through the results.

this is what the table would look like...

campaign | imp | clicks
A | 200000 | 100
B | 100000 | 40
C | 50000 | 10
D | 300000 | 200


and here's what i would like to achieve with a mysql query and php. I would like to create a new column CTR% and calculate the CTR for each row by looping through the table...


campaign | imp | clicks | CTR %
A | 200000 | 100 | 0.05
B | 100000 | 40 | 0.04
C | 50000 | 10 | 0.02
D | 300000 | 200 | 0.06


i've tried a few things that i've read up on by googling but none really worked (based on using a while loop). now i would like to wipe the slate clean and get your suggestions on what to do??

 
i think you so much... i didnt realize it was os simple... and i thank you!!!!!!!!!!!!!!!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top