Jump to content

Record Retrival Question


Bopo

Recommended Posts

Hi

 

I just want to make sure this is possible, as there's a few steps I will need to complete before it, basically here's what I want to do

 

  • Use a select * query to find all records with a ID number equal to the one I'm querying for
  • Within each record, there will be a column with a number of 1 to 5, I would loop through each record and add them all together to make a total
  • Next, the amount of records returned will be counted, and this number will be divided with the total above
  • Them the average is displayed on the page

 

So is this plausible?

Link to comment
https://forums.phpfreaks.com/topic/151681-record-retrival-question/
Share on other sites

Thanks for the reply, that function looks really useful

 

Each record will only have 1 number, which will range from 1-5, like

 

ID | Rating

1        3

1        5

1        5

1        2

1        4

1        5

1        3

1        2

1        4

1        4

 

Then loop through and add all the rating's up = 37

Divide by the amount of records, 10, therefore 37 / 10 = 3.7 avg

 

The only thing I'm going to struggle with is the looping through all that rating records and adding them all together, If someone could link to or provide a short example, I'd appreciate it :).

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.