Home Backend Development PHP Tutorial 投票管理程序_PHP

投票管理程序_PHP

Jun 01, 2016 pm 12:29 PM
a db echo sql vote program manage

投票管理程序

表结构
CREATE TABLE poll(Poll_Id INT (11) not null AUTO_INCREMENT,Poll_Name char(50) ,Poll_Del INT (10) DEFAULT '0' , PRIMARY KEY (Poll_Id))

CREATE TABLE pollsele(Pollsele_Id INT (11) not null AUTO_INCREMENT,Pollsele_Name char(50) ,Poll_Del INT (10) DEFAULT '0' , Pollsele_poll_Id INT (10) ,pollsele_num int (10), PRIMARY KEY (Pollsele_Id))
-------------------------------------------------------------------------------------------------
poll.php //主程序

$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 "

";
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 "

";
while($myrow=mysql_fetch_row($result))
{

echo "$myrow[0]";
echo " "; }
echo "
"; echo "
";
echo "";

echo "

";
echo "
"; echo "
";
mysql_close();
echo "
";
echo "

";
echo "管理"; echo "

"; ?>
-----------------------------------------------------------------------
poll_input.php //添加主题

$db =mysql_connect("localhost", "root","391450");
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($submit2!="添加")
{ echo "

";
echo "

";


echo "主题:";
echo "";



echo "";
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($submit1!="有效"&&$submit3!="删除")
{ echo "

";
echo "

";
echo "设置主题:";
echo "";
echo "";
echo "";
echo "";
echo "
";

}
else
{
if($submit1=="有效")
{
$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 //添加选项

$db =mysql_connect("localhost", "root","391450");
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($submit2!="添加")
{ echo "

";
echo "

";


echo "选项:";
echo "";



echo "";
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($submit1!="有效"&&$submit3!="无效")
{ echo "

";
echo "

";
echo "设置选项:";
echo "";
echo "";
echo "";
echo "";
echo "
";

}
else
{ $db =mysql_connect("localhost", "root","391450");
mysql_select_db("class",$db);
if ($submit1=="有效")
{
$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 //投票结果

if ($toupiao!=""){
$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 "你不能投空票!!!";}

?>

【本文版权归作者与奥索网共同拥有,如需转载,请注明作者及出处】
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn

Hot AI Tools

Undresser.AI Undress

Undresser.AI Undress

AI-powered app for creating realistic nude photos

AI Clothes Remover

AI Clothes Remover

Online AI tool for removing clothes from photos.

Undress AI Tool

Undress AI Tool

Undress images for free

Clothoff.io

Clothoff.io

AI clothes remover

AI Hentai Generator

AI Hentai Generator

Generate AI Hentai for free.

Hot Article

R.E.P.O. Energy Crystals Explained and What They Do (Yellow Crystal)
2 weeks ago By 尊渡假赌尊渡假赌尊渡假赌
Repo: How To Revive Teammates
4 weeks ago By 尊渡假赌尊渡假赌尊渡假赌
Hello Kitty Island Adventure: How To Get Giant Seeds
4 weeks ago By 尊渡假赌尊渡假赌尊渡假赌

Hot Tools

Notepad++7.3.1

Notepad++7.3.1

Easy-to-use and free code editor

SublimeText3 Chinese version

SublimeText3 Chinese version

Chinese version, very easy to use

Zend Studio 13.0.1

Zend Studio 13.0.1

Powerful PHP integrated development environment

Dreamweaver CS6

Dreamweaver CS6

Visual web development tools

SublimeText3 Mac version

SublimeText3 Mac version

God-level code editing software (SublimeText3)

How to make Google Maps the default map in iPhone How to make Google Maps the default map in iPhone Apr 17, 2024 pm 07:34 PM

The default map on the iPhone is Maps, Apple's proprietary geolocation provider. Although the map is getting better, it doesn't work well outside the United States. It has nothing to offer compared to Google Maps. In this article, we discuss the feasible steps to use Google Maps to become the default map on your iPhone. How to Make Google Maps the Default Map in iPhone Setting Google Maps as the default map app on your phone is easier than you think. Follow the steps below – Prerequisite steps – You must have Gmail installed on your phone. Step 1 – Open the AppStore. Step 2 – Search for “Gmail”. Step 3 – Click next to Gmail app

What is the difference between HQL and SQL in Hibernate framework? What is the difference between HQL and SQL in Hibernate framework? Apr 17, 2024 pm 02:57 PM

HQL and SQL are compared in the Hibernate framework: HQL (1. Object-oriented syntax, 2. Database-independent queries, 3. Type safety), while SQL directly operates the database (1. Database-independent standards, 2. Complex executable queries and data manipulation).

How to initiate WeChat voting How to initiate WeChat voting Feb 23, 2024 pm 12:20 PM

How to initiate WeChat voting? You can initiate voting function in WeChat, but most users don’t know how to initiate voting function in WeChat. Next is the graphic tutorial on how to initiate WeChat voting brought by the editor. Interested users please hurry up Come and take a look! WeChat usage tutorial How to initiate WeChat voting 1. First open the WeChat APP, click on the search box at the top of the main page to enter [Voting] and click [Group Voting] as shown below; 2. Then enter the group voting applet page and click [+ Voting] service button; 3. Finally, edit the content on the create group voting page to initiate voting.

Usage of division operation in Oracle SQL Usage of division operation in Oracle SQL Mar 10, 2024 pm 03:06 PM

"Usage of Division Operation in OracleSQL" In OracleSQL, division operation is one of the common mathematical operations. During data query and processing, division operations can help us calculate the ratio between fields or derive the logical relationship between specific values. This article will introduce the usage of division operation in OracleSQL and provide specific code examples. 1. Two ways of division operations in OracleSQL In OracleSQL, division operations can be performed in two different ways.

Comparative analysis of Oracle and DB2 database technology Comparative analysis of Oracle and DB2 database technology Mar 11, 2024 am 09:54 AM

Oracle and DB2 are two well-known relational database management systems (RDBMS) that are widely used in enterprise applications. In this article, we will compare the two database technologies of Oracle and DB2 and analyze them in detail, including analysis of their characteristics, performance, functions and usage examples. 1. Overview of Oracle database technology Oracle is a relational database management system developed by Oracle Corporation of the United States. It is widely used in enterprise-level applications and has strong performance and stability.

Comparison and differences of SQL syntax between Oracle and DB2 Comparison and differences of SQL syntax between Oracle and DB2 Mar 11, 2024 pm 12:09 PM

Oracle and DB2 are two commonly used relational database management systems, each of which has its own unique SQL syntax and characteristics. This article will compare and differ between the SQL syntax of Oracle and DB2, and provide specific code examples. Database connection In Oracle, use the following statement to connect to the database: CONNECTusername/password@database. In DB2, the statement to connect to the database is as follows: CONNECTTOdataba

What does the identity attribute in SQL mean? What does the identity attribute in SQL mean? Feb 19, 2024 am 11:24 AM

What is Identity in SQL? Specific code examples are needed. In SQL, Identity is a special data type used to generate auto-incrementing numbers. It is often used to uniquely identify each row of data in a table. The Identity column is often used in conjunction with the primary key column to ensure that each record has a unique identifier. This article will detail how to use Identity and some practical code examples. The basic way to use Identity is to use Identit when creating a table.

Clock app missing in iPhone: How to fix it Clock app missing in iPhone: How to fix it May 03, 2024 pm 09:19 PM

Is the clock app missing from your phone? The date and time will still appear on your iPhone's status bar. However, without the Clock app, you won’t be able to use world clock, stopwatch, alarm clock, and many other features. Therefore, fixing missing clock app should be at the top of your to-do list. These solutions can help you resolve this issue. Fix 1 – Place the Clock App If you mistakenly removed the Clock app from your home screen, you can put the Clock app back in its place. Step 1 – Unlock your iPhone and start swiping to the left until you reach the App Library page. Step 2 – Next, search for “clock” in the search box. Step 3 – When you see “Clock” below in the search results, press and hold it and

See all articles