Your IP : 216.73.216.40


Current Path : /var/www/html/mmishra/iws8/html/indem/
Upload File :
Current File : /var/www/html/mmishra/iws8/html/indem/celebrity-poll.inc

<a name="pg"><span id='title'>Opinion Poll for Effervescence Celebrity</span></a><br>
<?php
if (!isset($_SESSION["uid"])) {
	login($pg);
} else {
	$tbl = "pollChoice";
	//define subject
	$subject = 'Celebrity';
	$imagepath = '/celebrity';
	$id = $_REQUEST["id"];

	if ($id) {
        	if (mysql_num_rows(mysql_query("select * from pollScore where uid='$uid' and choice=$id"))) {
			echo "<h2 style='color:red;text-align:right'>You have already voted for Samples ";
			$rs = mysql_query("select * from pollScore where uid='$uid'");
			while ($o = mysql_fetch_object($rs)) {
				echo $o->choice . ", ";
			}
			echo " No repeated vote please.</h2>";
		} else {
			mysql_query("insert into pollScore(uid, choice,dated) values('$uid',$id,now())"); 
        		if (mysql_num_rows(mysql_query("select * from $tbl where id=$id"))) {
                		mysql_query("update $tbl set score=score+1 where id=$id");
        		}
		}
	} else if ($action == "del") {
        	mysql_query("delete from $tbl where id=$id");
	}

	$rs = mysql_query("select sum(score) as tot from $tbl group by subject having subject='$subject'");
	if ($rs) {
		$o = mysql_fetch_object($rs);
		$tot = $o->tot;
	}
	echo "<div align='right'><font color=red>Total polls: $tot (One can poll only once per option, 
	link would be disabled against options already voted for)</font></div> 
	<table width='90%' border='1' align='center'>
	<tr><th>No.</th><th>Option (click over for enlarged view of images)</th><th>Score (descending)</th></tr>";

	$rs = mysql_query("select * from $tbl where subject='$subject' order by score desc");
	while ($o = mysql_fetch_object($rs)) {
		$i++;
		$per = ($o->score / $tot) * 100;
		echo "<tr valign='center'><td>$i</td>
		<td align='center'><a href='$imagepath/fullsize/$o->image'>";
		if ($o->image) echo "<img src='$imagepath/$o->image' width='100' height='100'>";
		echo "</a>$o->description</td><td align='center'>$o->score (". number_format($per,2) ."%)<br>[ ";
        	if (mysql_num_rows(mysql_query("select * from pollScore where uid='$uid' and choice=$o->id"))) {
			echo "Voted";
		} else {
			echo "Not Voted";
			//echo "<a href='?pg=$pg&subject=$subject&id=$o->id'>Cast Your Vote</a>";
		}
		echo " ]</td></tr>";
	}
	echo "</table>";
}
?>