Voting management procedures

Source: Internet
Author: User
Tags valid
Voting management procedures

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

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

? $db =mysql_connect ("localhost", "root", "391450");
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 "<table align=center bgcolor=aabbcc width=250 hight=450 border=0 style= ' border:1px solid rgb (0,0,0) ' >";
echo "<td align=center bgcolor=99aabb style= ' border:1px solid rgb (255,255,255) ' >";

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 "<form action= ' pollsee.php?poll_id= $myrow [0] ' method= ' post ' target=_blank>";
echo "<p align=center>";
while ($myrow =mysql_fetch_row ($result))
{

echo "<input type= ' Radio ' Name=toupiao value= ' $myrow [0] ' > $myrow [0]";
echo ""; }
echo "<br>"; echo "<br>";
echo "<input type=submit name=submit value= ' vote ' >";

echo "</p>";
echo "</form>"; echo "</td>";
echo "</table>";
Mysql_close ();
echo "<br>";
echo "<p align=right>";
echo "<a href=poll_input> management </a>";     echo "</p>"; ?>
-----------------------------------------------------------------------
poll_input.php//Add theme

? $db =mysql_connect ("localhost", "root", "391450");
mysql_select_db ("Class", $db);
$sql = "Select Poll_id,poll_name,poll_del from Poll";
echo "<table width=300 hight=560 bgcolor=aabbcc align=center style= ' border:1px solid rgb (0,0,0) ' >";
$result =mysql_query ($sql);
while ($my =mysql_fetch_row ($result))
{

echo "<tr>", echo "<td align=center width=50 bgcolor=99aabb style= border:1px ' solid rgb (255,255,255) ' >"; echo $my [0];echo "</td>";
echo "<td align=center width=200 bgcolor=99aabb style= ' border:1px solid rgb (255,255,255) ' ><a href= pollsele.php?id= $my [0]> $my [1]</a></td> ";
echo "<td align=center width=50 bgcolor=99aabb style= ' border:1px solid rgb (255,255,255) ' >"; echo $my [2];echo] < /TD> ";
echo "</tr>";

echo "</table>";
?>
?

if ($submit 2!= "add")
{echo "<p align=center>";
echo "<form action= ' poll_input.php ' method= ' post ' >";


echo "<font color=004080> theme:</font>";
echo "<input type=text name=title size=30 value= ' >";



echo "<input type=submit name=submit2 value= ' Add ' >";
echo "</p>";
echo "</form>"; }

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 "<meta Http-equiv=refresh content= ' 1;  url=poll_input.php ' > '; }
if ($submit 1!= "valid" && $submit 3!= "Delete")
{echo "<p align=center>";
echo "<form action= ' poll_input.php ' method= ' post ' >";
echo "<font color=004080> set Theme:</font>";
echo "<select name= ' Sele ' size=1>";
$db =mysql_connect ("localhost", "root", "391450");
mysql_select_db ("Class", $db);
$sql = "Select poll_id from Poll";
$result = mysql_query ($sql);
Mysql_close ();
while ($myrow =mysql_fetch_row ($result))
{echo "<option value= ' $myrow [0] ' > $myrow [0]";}

echo "</select>";
echo "<input type=submit name=submit1 value= ' effective ' >";
echo "<input type=submit name=submit3 value= ' delete ' >";
echo "</p>";
echo "</FORM>";

}
Else
{
if ($submit 1== "valid")
{
$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 "<meta Http-equiv=refresh content= ' 1;      url=poll_input.php ' > '; }
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 "<meta Http-equiv=refresh content= ' 1;      url=poll_input.php ' > '; }

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

? $db =mysql_connect ("localhost", "root", "391450");
mysql_select_db ("

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.