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) )); Link to comment https://forums.phpfreaks.com/topic/85308-solved-voting/ Share on other sites More sharing options...
everlifefree Posted January 10, 2008 Author Share Posted January 10, 2008 PLEASE HELP>>> Link to comment https://forums.phpfreaks.com/topic/85308-solved-voting/#findComment-435680 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? Link to comment https://forums.phpfreaks.com/topic/85308-solved-voting/#findComment-435683 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 Link to comment https://forums.phpfreaks.com/topic/85308-solved-voting/#findComment-435826 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.