Page 1 of 1
question w/ inserting data
Posted: Thu Sep 06, 2007 10:43 pm
by i shot love
I'm making a website for music ratings. I'm pretty much new to all this but have been reading online tutorials and stuff, made some progress. There is one major thing I need. I'm giving the viewers the ability to enter number ratings (0.00-10.00) into a text box for each song on the current album's page they're on. I would like for them to be able to click a submit button that will send all those ratings into my database, average it with the currents rating in there, then output them back to the website. To find the average, I'm assuming it would have to keep track of how many times a rating has been submitted per song, which I don't know how to do either other than logging every rating in a table. I would also like to keep track of how many times each song has been rated so people know if the 9.5 rating a song has is legit and from 50 people or just 2. So if anybody can help me out, I'd really appreciate it.
Posted: Fri Sep 07, 2007 10:13 am
by TheMoose
You could, in theory, keep track of each separate rating if you wanted to do more with those than just an average. If you wanted a simple average and nothing more, just have 2 extra columns for a song, Total and Votes. Total is a simple sum of the ratings (if a song was rated a 10, 5 times, the Total would be 50), and Votes is a count of the ratings (5 in this case). You then just return Total/Votes, and there's your average.
Posted: Fri Sep 07, 2007 3:49 pm
by i shot love
Yeah, that's what I figured I would have to do, I didn't know if there was an easier way to do that rather than keeping track of everything. Ok so I'll set up my database for that but can you go into detail a little more with the coding? Like I said, i'm new to all this stuff so I'm really just learning as I go along. I'm not sure what the code would be that would take each rating from the text boxes and send them into the database upon a click of the submit button.
Posted: Fri Sep 07, 2007 6:11 pm
by califdon
You're asking for a tutorial in PHP. Here's one:
http://www.w3schools.com/php/default.asp