everlifefree Posted January 10, 2008 Share Posted January 10, 2008 Here's my voting code but I can't figure out to make it do more than just compute the average I want it to add 1 if the click on they 1 button and -1 in they click on the -1 button. Please help // COMPUTE RATINGS /////////// if (!is_array($rating = unpk($row["rating"]))) $rating = array(); if (me("id") > 0 and in_array(me("id"), array_keys($rating))) $tpl -> Zone("rating", "disabled"); else { if (isset($_GET["rate"]) and $_GET["rate"] > -2 and $_GET["rate"] < 2 and is_numeric($_GET["rate"])) { $rating[me("id")] = $_GET["rate"]; myQ(" UPDATE `[x]nark` SET `rating`='".pk($rating)."', `rating_hits`='".count($rating)."', `rating_avg`='".round(array_sum($rating) / count($rating), 1)."' WHERE `id`='{$row["id"]}' LIMIT 1 "); $GLOBALS["CHROMELESS_MODE"] = true; $tpl -> LoadThis($tpl -> Zone("rating", "disabled", 1)); $tpl -> AssignArray(array( "rate.hits" => count($rating), "rate.avg" => round(array_sum($rating) / count($rating), 1) )); $tpl -> Flush(); die(); } } $tpl -> Zone("rating", "enabled"); $tpl -> AssignArray(array( "rate.hits" => count($rating), "rate.avg" => (count($rating) > 0 ? round(array_sum($rating) / count($rating), 1) : 0) )); Quote Link to comment Share on other sites More sharing options...
everlifefree Posted January 10, 2008 Author Share Posted January 10, 2008 PLEASE HELP>>> Quote Link to comment Share on other sites More sharing options...
cooldude832 Posted January 10, 2008 Share Posted January 10, 2008 well I don't see a SELECT query so how are you even getting the data? Quote Link to comment Share on other sites More sharing options...
everlifefree Posted January 10, 2008 Author Share Posted January 10, 2008 I'm getting the data by a link "http://mysite.com?L=folder.page&id=videoid&rate=1" that will put the 1 value to my database but the negative input doesn't subtract from the 1 i put up when it is clicked Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.