I need a crash course on php. I'm working with code that has already been written and I just need to alter it. Here's what I've discovered:
The user rates a song - the rated info is stored in a DB called 'votedata' which has fields for 'lid' (which is the songs ID#) and 'rating' (which holds the actual rating number from the last rater).
There's another DB called 'files' that has fields for all file info. One field is 'xfid' (which holds the song ID#) and one field is 'rating' (which holds the current rating for the song).
What is currently happening is the code is telling the DB to add a new row in DB 'votedata' and it is placing all info from the current rating into this new row. basically, the code is then copying the 'rating' data to the 'rating' field in the DB 'files'.
I need the code to take the data from the DB 'votedata' in the filed 'rating' and ADD IT TO the DB 'files' in the field 'rating', and to leave the sum in that same field.
This should be easy right!
The code I'm working with is open source from a xoops module called Debaser. the whole purpose for this is to set up a user voted chart of top rated songs.
Here's the section of code that I think I should be working on changing.
// All is well. Add to Line Item Rate to DB.
$newid = $xoopsDB->genId($xoopsDB->prefix('debaservotedata'). "ratingid_seq");
$datetime = time();
$xoopsDB->query("INSERT INTO ".$xoopsDB->prefix('debaservotedata')." (ratingid, lid, ratinguser, rating, ratinghostname, ratingtimestamp) VALUES ($newid, $lid, $ratinguser, $rating, '$ip', $datetime)" );
// All is well. Calculate Score & Add to Summary (for quick retrieval & sorting) to DB.
updatedebaserrating($lid);
$ratemessage = MD_DEBASER_VOTEAPPRE . "<br />" . sprintf(_MD_DEBASER_THANKYOU, $xoopsConfig['sitename']);
redirect_header("singlefile.php?id=$lid", 1, $ratemessage);
exit();
I know what I need to do, I just can't figure out how to do it. Can you help? Is there a "PHP and MySQL for Dummies" website out there somewhere?
My site is www.brimstonerecords.com if anyone is currious........🙂