Voting Management Program _php Tutorial

Source: Internet
Author: User
Voting management procedures

Table structure
CREATE TABLE Poll (poll_id Int (one) not null Auto_increment,poll_name char (), Poll_del Int (ten) DEFAULT ' 0 ', PRIMARY KEY (poll_id))

CREATE TABLE Pollsele (pollsele_id int (one) not null Auto_increment,pollsele_name char (), Poll_del Int (ten) DEFAULT ' 0 ', pollsele_poll_id Int (ten), Pollsele_num Int (ten), PRIMARY KEY (pollsele_id))
-------------------------------------------------------------------------------------------------
poll.php//Main program

mysql_select_db ("Class", $db);
$sql = "Select Poll_id,poll_name from Poll where poll_del= ' 1 '";
@ $result = mysql_query ($sql);


$myrow =mysql_fetch_row ($result);
echo "

"; echo " "; echo "
";

echo "$myrow [1]";



$sql = "Select pollsele_name,pollsele_poll_id from Pollsele where pollsele_del= ' 0 ' and pollsele_poll_id= ' $myrow [0] '";
@ $result = mysql_query ($sql);
echo ""; echo "
";
Mysql_close ();
echo "
";
echo "

";
echo "Management"; echo "

";?>
-----------------------------------------------------------------------
poll_input.php//Add theme

mysql_select_db ("Class", $db);
$sql = "Select Poll_id,poll_name,poll_del from Poll";
echo "









"; $result =mysql_query ($sql); while ($my =mysql_fetch_row ($result)) {echo " "; Echo" "; echo " "; echo " "; echo " "; } echo "
"Echo $my [0];echo]$my [1]"Echo $my [2];echo]
";
?>



if ($submit 2!= "add")
{echo "

";
echo "";}

Else
{$db =mysql_connect ("localhost", "root", "391450");
mysql_select_db ("Class", $db);
$sql = "Select Poll_name from Poll where poll_name= ' $title '";
mysql_query ($sql);


$sql = "INSERT into poll values (', ' $title ', ')";
mysql_query ($sql);
Mysql_close ();
echo " ";}
if ($submit 1!= "active" && $submit 3!= "Delete")
{echo "

";
echo "";

}
Else
{
if ($submit 1== "active")
{
$db =mysql_connect ("localhost", "root", "391450");
mysql_select_db ("Class", $db);

$sql = "Update poll set poll_del= ' 0";
$result = mysql_query ($sql);

$sql = "Update poll set poll_del= ' 1 ' where poll_id= ' $sele '";
$result = mysql_query ($sql);

Mysql_close ();
echo " "; }
Else
{$db =mysql_connect ("localhost", "root", "391450");
mysql_select_db ("Class", $db);
$sql = "Delete from poll where poll_id= ' $sele '";
$result = mysql_query ($sql);
$sql = "Delete from Pollsele where pollsele_poll_id= ' $sele '";
mysql_query ($sql);
Mysql_close ();
echo " "; }

}
?>
--------------------------------------------------------------------
pollsele.php//Add options

mysql_select_db ("Class", $db);
$sql = "Select Pollsele_id,pollsele_name,pollsele_del,pollsele_num from Pollsele where pollsele_poll_id= ' $id '";
echo "












"; @ $result =mysql_query ($sql); while ($my =mysql_fetch_row ($result)) {echo " "; Echo" "; echo " "; echo " "; echo " "; echo " "; } echo "
"Echo $my [0];echo]$my [1]"Echo $my [2];echo]"Echo $my [3];echo]
";
?>



if ($submit 2!= "add")
{echo "

";
echo "";}

Else
{$db =mysql_connect ("localhost", "root", "391450");
mysql_select_db ("Class", $db);


$sql = "INSERT into Pollsele values (' ', ' $title ', ' ', ' $id ', ')";
mysql_query ($sql);
Mysql_close ();
echo " ";}
if ($submit 1!= "valid" && $submit 3!= "Invalid")
{echo "

";
echo "";

}
Else
{$db =mysql_connect ("localhost", "root", "391450");
mysql_select_db ("Class", $db);
if ($submit 1== "active")
{
$sql = "Update pollsele set pollsele_del= ' 0 ' where pollsele_id= ' $sele '";
$result = mysql_query ($sql);}
Else
{
$sql = "Update Pollsele set pollsele_del= ' 1 ' where pollsele_id= ' $sele '";
$result = mysql_query ($sql); }
Mysql_close ();
echo " "; }


?>
----------------------------------------------------------------------
pollsee.php//Poll results

$db =mysql_connect ("localhost", "root", "391450");
mysql_select_db ("Class", $db);
$sql = "Select Pollsele_name,pollsele_num from Pollsele where pollsele_name= ' $toupiao '";
@ $result = mysql_query ($sql);
$myrow =mysql_fetch_row ($result);
$poll _num= $myrow [1];
$poll _num= $poll _num+1;
$sql = "Update pollsele set pollsele_num= ' $poll _num ' where pollsele_name= ' $toupiao '";
mysql_query ($sql);

$sql = "Select Poll_name from Poll where poll_id= ' $poll _id '";
@ $result = mysql_query ($sql);
$title =mysql_fetch_row ($result);
echo "

";
echo $title [0]; echo "

";
echo "
";
$sql = "Select Pollsele_name,pollsele_num from Pollsele where pollsele_del= ' 0 ' and pollsele_poll_id= ' $poll _id '";
@ $result = mysql_query ($sql);
echo "

"; while ($myrow =mysql_fetch_row ($result)) {echo " "; echo " ";} echo "
";
echo $myrow [0];echo]
"; Echo $myrow [1]; echo "
"; }
Else
{echo "You cannot cast a blank ticket!!!";}

?>

"The copyright of this article is owned by the author and house Orso near net, if need to reprint, please specify the author and source"

http://www.bkjia.com/PHPjc/316512.html www.bkjia.com true http://www.bkjia.com/PHPjc/316512.html techarticle Vote Manager Table Structure CREATE table poll (poll_id Int (one) not null Auto_increment,poll_name char (0), Poll_del int ', PRIMARY KEY (poll_id)) CREATE TABLE polls ...

  • Contact Us

    The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

    If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

    A Free Trial That Lets You Build Big!

    Start building with 50+ products and up to 12 months usage for Elastic Compute Service

    • Sales Support

      1 on 1 presale consultation

    • After-Sales Support

      24/7 Technical Support 6 Free Tickets per Quarter Faster Response

    • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.