this is my vote_result script its not the most advanced
<?php
// votes results
// and sort the database
include "config.php";
$db = mysql_connect($db_host,$db_user,$db_pass);
mysql_select_db ($db_name) or die ("Cannot connect to database");
// We are now connected to the database
$id = $id;
$query = "SELECT * FROM coupons WHERE id = '$id'";
$result = mysql_query($query);
while ($r=mysql_fetch_array($result))
{
$id=$r["id"];
$yes=$r["yes"];
$no=$r["no"];
}
$yes = $yes;
$no = $no;
$totalno = ($yes+$no);
// % yes
$yespercent = ($yes / $totalno) * 100;
// %no
$nopercent = ($no / $totalno) * 100;
echo "Yes: $yespercent%"; echo " | No: $nopercent%";
// calculation (result (yes no) / totalnumber) * 100
?>
and my dispaypage
<?php $host = $_GET['host'];
include "config.php";
$db = mysql_connect($db_host,$db_user,$db_pass);
mysql_select_db ($db_name) or die ("Cannot connect to database");
//We are now connected to the database
$query = "SELECT * FROM coupons WHERE registrar = '".$_GET['registrar']."' AND approved = 'yes'";
$result = mysql_query($query);
while ($r=mysql_fetch_array($result))
{
$id=$r["id"];
$discount=$r["discount"];
$coupon=$r["coupon"];
$expires=$r["expires"];
$registrar=$r["registrar"];
$webaddress=$r["webaddress"];
$webname=$r["webname"];
?>
<p>Coupon Code: <strong><?php echo $coupon;?></strong><br />
Discount: <?php echo $discount;?><br />
Expires: <?php echo $expires;?><br />
Link: <?php echo "<a href=\"$webaddress\">$webname</a>";?><br />
<a href="vote.php?id=<?php echo $id;?>&action=yes" onclick="window.open(this.href, 'child', 'scrollbars,width=250,height=250'); return false"><img src="img/accept.png" alt="This Works" width="16" height="16" border="0" /></a> <a href="vote.php?id=<?php echo $id;?>&action=no" onclick="window.open(this.href, 'child', 'scrollbars,width=250,height=250'); return false"><img src="img/delete.png" alt="Does Not Work" width="16" height="16" border="0" /></a>
<?php
include "vote_results.inc"; }?>