Jump to content

Rating System Get ID


balkan7

Recommended Posts

If i try to rate some of download list just rate id=1 you cannot rate other id.

I need help for get id for show hide tag.

code is:

<?php
echo "<script type='text/javascript' language='JavaScript'>
function showhide(id){
if (document.getElementById){
obj = document.getElementById(id);
if (obj.style.display == 'none'){
obj.style.display = '';
} else {
obj.style.display = 'none';
}
}
}
</script>";
echo "<a href='#' onclick=\"showhide('".$data['download_id']."_ratings'); return(false);\"><img src='".DLL."ratings.png' border='0' title='Ratings' alt='Ratings' /></a>";
echo "<div id='".$data['download_id']."_ratings' style='display: none;'>";
if($allow_ratings != false){
showratings("D", $data['download_id'], FUSION_SELF."?cat_id=".$_GET['cat_id']);
}
echo "</div>";

Link to comment
https://forums.phpfreaks.com/topic/111370-rating-system-get-id/
Share on other sites

try

obj = document.getElementById(id+"_ratings");

 

instead of

obj = document.getElementById(id);

Java script working perfectly, when i open div tag for show and hide show me real id of download so when i try to rate that download id in datebase inserting only first id (1)

so this is function for call rating:

showratings("D", $data['download_id'], FUSION_SELF."?cat_id=".$_GET['cat_id']);

 

rating function:

function showratings($rating_type, $rating_item_id, $rating_link)

 

Link to comment
https://forums.phpfreaks.com/topic/111370-rating-system-get-id/#findComment-571742
Share on other sites

code is:

<?php 
function showratings($rating_type, $rating_item_id, $rating_link) {

global $locale, $userdata;

if (iMEMBER) {
	$d_rating = dbarray(dbquery("SELECT rating_vote,rating_datestamp FROM ".DB_RATINGS." WHERE rating_item_id='".$rating_item_id."' AND rating_type='".$rating_type."' AND rating_user='".$userdata['user_id']."'"));
	if (isset($_POST['post_rating'])) {
		if (isnum($_POST['rating']) && $_POST['rating'] > 0 && $_POST['rating'] < 6 && !isset($d_rating['rating_vote'])) {
			$result = dbquery("INSERT INTO ".DB_RATINGS." (rating_item_id, rating_type, rating_user, rating_vote, rating_datestamp, rating_ip) VALUES ('$rating_item_id', '$rating_type', '".$userdata['user_id']."', '".$_POST['rating']."', '".time()."', '".USER_IP."')");
		}
		redirect($rating_link);
	} elseif (isset($_POST['remove_rating'])) {
		$result = dbquery("DELETE FROM ".DB_RATINGS." WHERE rating_item_id='$rating_item_id' AND rating_type='$rating_type' AND rating_user='".$userdata['user_id']."'");
		redirect($rating_link);
	}
}
$ratings = array(5 => $locale['r120'], 4 => $locale['r121'], 3 => $locale['r122'], 2 => $locale['r123'], 1 => $locale['r124']);

opentable($locale['r100']);
if (!iMEMBER) {
	echo "<div style='text-align:center'>".$locale['r104']."</div>\n";
} elseif (isset($d_rating['rating_vote'])) {
	echo "<div style='text-align:center'>\n";
	echo "<form name='removerating' method='post' action='".$rating_link."'>\n";
	echo sprintf($locale['r105'], $ratings[$d_rating['rating_vote']], showdate("longdate", $d_rating['rating_datestamp']))."<br /><br />\n";
	echo "<input type='submit' name='remove_rating' value='".$locale['r102']."' class='button' />\n";
	echo "</form>\n</div>\n";
} else {
	echo "<div style='text-align:center'>\n";
	echo "<form name='postrating' method='post' action='".$rating_link."'>\n";
	echo $locale['r106'].": <select name='rating' class='textbox'>\n";
	echo "<option value='0'>".$locale['r107']."</option>\n";
	foreach($ratings as $rating=>$rating_info) {
		echo "<option value='".$rating."'>$rating_info</option>\n";
	}
	echo "</select>\n";
	echo "<input type='submit' name='post_rating' value='".$locale['r103']."' class='button' />\n";
	echo "</form>\n</div>";
}
echo "<hr />";
$tot_votes = dbcount("(rating_item_id)", DB_RATINGS, "rating_item_id='".$rating_item_id."' AND rating_type='".$rating_type."'");
if($tot_votes){
	echo "<table cellpadding='0' cellspacing='1' class='tbl-border center'>\n";
	foreach($ratings as $rating=>$rating_info) {
		$num_votes = dbcount("(rating_item_id)", DB_RATINGS, "rating_item_id='".$rating_item_id."' AND rating_type='".$rating_type."' AND rating_vote='".$rating."'");
		$pct_rating = number_format(100 / $tot_votes * $num_votes);
		if ($num_votes == 0) {
			$votecount = "[".$locale['r108']."]";
		} elseif ($num_votes == 1) {
			$votecount = "[1 ".$locale['r109']."]";
		} else {
			$votecount = "[".$num_votes." ".$locale['r110']."]";
		}
		$class = ($rating % 2==0?"tbl1":"tbl2");
		echo "<tr>\n";
		echo "<td class='$class'>".$rating_info."</td>\n";
		echo "<td width='250' class='$class'><img src='".get_image("pollbar")."' alt='".$rating_info."' height='12' width='".$pct_rating."%' class='poll' /></td>\n";
		echo "<td class='$class'>".$pct_rating."%</td>\n";
		echo "<td class='$class'>".$votecount."</td>\n";
		echo "</tr>\n";
	}
	echo "</table>\n";
}else{
	echo "<div style='text-align:center'>".$locale['r101']."</div>\n";
}
closetable();
}
?>

Link to comment
https://forums.phpfreaks.com/topic/111370-rating-system-get-id/#findComment-571774
Share on other sites

maybe this is solutions but i need real code.

if i add in:

echo "<input type='submit' name='post_rating".$rating_item_id."' value='".$locale['r103']."' class='button' />\n";
echo "<form name='postrating".$rating_item_id."' method='post' action='".$rating_link."'>\n";

now cooming post:

if (isset($_POST['post_rating'])) {

now we need post_rating along with rating_item_id convert to rating_item_id and place into datebase.

Plz help i need this.

Link to comment
https://forums.phpfreaks.com/topic/111370-rating-system-get-id/#findComment-573202
Share on other sites

Archived

This topic is now archived and is closed to further replies.

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