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/tshirt-poll.inc

<h1>Opinion Poll (T-Shirt Design)</h1>
<marquee><h2>Final results according to deadline (23-08-2010 22:00:00) of polling.</h2></marquee>
<?php
$tbl = "pollChoice";
//define subject
$subject = 'T-Shirt';
$imagepath = 'tshirt';
$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'");
$rs = mysql_query("select sum(poll) 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");
$rs = mysql_query("select * from $tbl where subject='$subject' order by poll desc");
while ($o = mysql_fetch_object($rs)) {
	$i++;
	//$per = ($o->score / $tot) * 100;
	$per = ($o->poll / $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/" . str_replace(".jpg","",$o->image) . "-1.jpg' width='100' height='100'>";
	echo "</a><br>Sample #$o->id ($o->image)</td><td align='center'>$o->poll (". number_format($per,2) ."%)<br>[ ";
	$rs1 = mysql_query("select count(choice) no from pollScore group by choice having dated < '2010-08-23 22:00:01'");
		 
       	if (mysql_num_rows(mysql_query("select * from pollScore where uid='$uid' and choice=$o->id"))) {
		echo "Voted";
	} else {
		echo "...";//<a href='?pg=$pg&subject=$subject&id=$o->id'>Cast Your Vote</a>";
	}
		
	echo " ]</td></tr>";
}
echo "</table>";

?>