Location: PHPKode > scripts > Voting system > voting-system-61721/main.php
<?php
//overview
include('database.php');
$query="SELECT * FROM polls1 ORDER BY id DESC LIMIT 1";
$rez=mysql_query($query);
$row=mysql_fetch_array($rez);
$id=$row['id']; 
print
"
<center>
  <form action=\"".$_SERVER['php_self']."\" method=\"POST\">
  <br>\"".$row['quest']."\"<br />
  <br>\"".$row['a']."\"<input type=\"radio\" name=\"a\"><br />
  <br>\"".$row['b']."\"<input type=\"radio\" name=\"b\"><br />
  <br>\"".$row['c']."\"<input type=\"radio\" name=\"c\"><br />
  <br>\"".$row['d']."\"<input type=\"radio\" name=\"d\"><br />
  <input type=\"submit\" name=\"action\" value=\"Send!\">
  </form>
  </center>
  ";
  if(isset($_POST['action']))
  {
    $a=$_POST['a'];
    $b=$_POST['b'];
    $c=$_POST['c'];
    $d=$_POST['d'];
  if(isset($a))
    {
     
	  $query1="SELECT a FROM results2 ORDER BY id DESC LIMIT 1";
	  $rez1=mysql_query($query1);
	  $row=mysql_fetch_array($rez1);
	  $row1=$row['a'] + 1;
	  $query2="UPDATE results2 SET a='$row1' WHERE id = $id";
	  $rez2=mysql_query($query2);
	  
	}
	else if(isset($b))
	{
	  $query1="SELECT b FROM results2 ORDER BY id DESC LIMIT 1";
	  $rez1=mysql_query($query1);
	  $row=mysql_fetch_array($rez1);
	  $row1=$row['b'] + 1;
	  $query2="UPDATE results2 SET b = '$row1' WHERE id = $id";
	  $rez2=mysql_query($query2);
	}
	else if(isset($c))
	{
	  $query1="SELECT c FROM results2 ORDER BY id DESC LIMIT 1";
	  $rez1=mysql_query($query1);
	  $row=mysql_fetch_array($rez1);
	  $row1=$row['c'] + 1;
	  $query2="UPDATE results2 SET c = '$row1' WHERE id = $id";
	  $rez2=mysql_query($query2);
	}
	else if(isset($d))
	{
	  $query1="SELECT d FROM results2 ORDER BY id DESC LIMIT 1";
	  $rez1=mysql_query($query1);
	  $row=mysql_fetch_array($rez1);
	  $row1=$row['d'] + 1;
	  $query2="UPDATE results2 SET d = '$row1' WHERE id = $id";
	  $rez2=mysql_query($query2);
	}
	}
print "<a href=results.php>Results</a>";	
?>
Return current item: Voting system