Jump to content

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 :).

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.