We often need to make multiple choices for users, such as allowing users to select multiple items in the list and delete the selected items. Today, we will give an example to illustrate how PHP and JavaScript process multiple choices. Today, we are working on a voting system to vote for items in the itemtable table of the MySQL database, and each individual IP address can only vote for two votes. Table itemtable is a type of item that we often need to make multiple choices for users. for example, you can select multiple items in the list and delete the selected items. Today, we will give an example to illustrate how PHP and JavaScript process multiple choices. Today, we are working on a voting system to vote for items in the itemtable table of the MySQL database, and each individual IP address can only vote for two votes.
The itemtable is created using the following MySQL statement:
Create table 'itemtable '(
'Id' TINYINT (4) not null AUTO_INCREMENT,
'Name' VARCHAR (50) not null,
'Votes 'SMALLINT (6) not null,
Primary key ('id ')
);
The field "name" is the name of the List project, and "votes" is the number of votes. We also need to create a table "voteiptable" to record the IP address of the voting User:
Create table 'voteiptable '(
'Id' SMALLINT (6) not null,
'Voteip' VARCHAR (15) not null,
Primary key ('id ')
);
Next we will write the file "multivote. php". today we will use a database file "dbclass. php ".
We often need to make multiple choices for users, such as allowing users to select multiple items in the list and delete the selected items. Today, we will give an example to illustrate how PHP and JavaScript process multiple choices. Today, we are working on a voting system to vote for items in the itemtable table of the MySQL database, and each individual IP address can only vote for two votes.
The itemtable is created using the following MySQL statement:
Create table 'itemtable '(
'Id' TINYINT (4) not null AUTO_INCREMENT,
'Name' VARCHAR (50) not null,
'Votes 'SMALLINT (6) not null,
Primary key ('id ')
);
The field "name" is the name of the List project, and "votes" is the number of votes. We also need to create a table "voteiptable" to record the IP address of the voting User:
Create table 'voteiptable '(
'Id' SMALLINT (6) not null,
'Voteip' VARCHAR (15) not null,
Primary key ('id ')
);
Next we will write the file "multivote. php". today we will use a database file "dbclass. php ".
Please vote
// Contains database files:
Include_once ("dbclass. php ")
// Check whether the IP address has been voted:
If ($ db-> getfirst ("select * from iptable where voteip = '$ _ SERVER [REMOTE_ADDR]'") {
Echo "you have already voted. thank you for your participation! ";
}
// This is the voting project list page:
If (! $ Action ){
Echo"
";
?>