KeywordsHow PHP and JavaScript handle multiple choices
We often have to make multiple choices for the user to process, such as allowing the user to select multiple items for a list item and then delete the selected item. Today's example shows how PHP and JavaScript handle multiple choices. What we're doing today is a voting system that polls the MySQL database itemtable table, and can only vote for two votes per individual IP.
Table ItemTable is established by the following MySQL statements:
CREATE TABLE ' itemtable ' ( ' ID ' TINYINT (4) Not NULL auto_increment, ' Name ' VARCHAR (not NULL), ' Votes ' SMALLINT (6) Not NULL, PRIMARY KEY (' id ') );
Where the field "name" is the list item name, "votes" is the number of votes obtained. We also create a table "voteiptable" to record the IP of the voting user:
CREATE TABLE ' voteiptable ' ( ' ID ' SMALLINT (6) Not NULL, ' Voteip ' VARCHAR (not NULL), PRIMARY KEY (' id ') );
Below we write the file "multivote.php", today we will use a database class file "dbclass.php".
We can see that both the client's JavaScript and the server-side PHP have many similarities in the processing of multiple choices, and of course there are differences. This is a more classic multi-option processing program, if you do not limit the user's options, it is simpler.
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.