Home  >  Article  >  Backend Development  >  Processing of multiple selections with PHP and javascript_PHP tutorial

Processing of multiple selections with PHP and javascript_PHP tutorial

WBOY
WBOYOriginal
2016-07-21 16:10:05778browse

We often need to allow users to make multiple choices for processing, such as allowing users to select multiple items on a list and then delete the selected items, etc. Today I will give an example to illustrate how PHP and JavaScript handle multiple selections respectively. What we are working on today is a voting system to vote for items in the itemtable table of the MySQL database, and each IP can only cast two votes.



The table itemtable is created through 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 item, and "votes" is the number of votes received. We also need to create a table "voteiptable" to record the IP of voting users:

CREATE TABLE `voteiptable` (
`id` SMALLINT( 6 ) NOT NULL ,
`voteip` VARCHAR( 15 ) NOT NULL,
PRIMARY KEY ( `id` )
);

Next we write the file "multivote.php". Today we will use a database class file "dbclass.php".




We can find that there are many similarities in the processing of multiple selections by client-side JavaScript and server-side PHP, but of course there are also differences. This is a relatively classic multi-option processing program. It would be simpler if the user's options are not limited.

www.bkjia.comtruehttp: //www.bkjia.com/PHPjc/314307.htmlTechArticleWe often need to give users multiple choices for processing, such as allowing users to select multiple items on a list and then delete the selection. Fixed items etc. Today I will give an example to illustrate how PHP and JavaScript are processed respectively...
Statement:
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
Previous article:3_PHP TutorialNext article:3_PHP Tutorial