Ask how to write post on a simple voting page-php Tutorial

Source: Internet
Author: User
Ask a simple voting page. how to write a simple voting function in post? if the php post value is consistent with the database content, count + 1 is as follows:
 
  


Now I want to change check. php from a single box to multiple ones for online check. I want to use arrays and change the code
 
  
It won't work. I really don't understand it. please take a look at the code. thank you very much!

Again, the format of the database is "1 Space, 1 Space, 1", which is fixed.
On the voting page, if the voting succeeds and the count of the database is indeed + 1, the echo voting succeeds. if the voting fails (for example, the format is incorrect or the input is incorrect) echo
Voting failed. how can this problem be solved? We will offer you an offer at 90!


Reply to discussion (solution)

$ _ POST ['test'] will be able to get these items, and the result is an array

$ _ POST ['test [] '] cannot obtain the value. you need to obtain $ _ POST ['test']. its value is an array. for example, it may be:
Array ('20140901', '20160901', '20160901 ')

Then you need to traverse the array and insert it into the database. your database cannot simply get it with an equal sign:
Tl01 = '$ test '"
Mysql does not have such a statement. mysql must use in to process multiple statements:
Where tl01 in ('20140901', '20160901', '20160901 ')

Therefore, you need to convert the array to the string required by mysql: ('20160301', '20160301', '20160301') to implement your function.

$ _ POST ['test [] '] cannot obtain the value. you need to obtain $ _ POST ['test']. its value is an array. for example, it may be:
Array ('20140901', '20160901', '20160901 ')

Then you need to traverse the array and insert it into the database. your database cannot simply get it with an equal sign:
Tl01 = '$ test '"
Mysql does not have such a statement. mysql must use in to process multiple statements:
Where tl01 in ('20140901', '20160901', '20160901 ')

Therefore, you need to convert the array to the string required by mysql: ('20160301', '20160301', '20160301') to implement your function.



Thank you very much for your answers. I really cannot find a similar case column in the book and on the internet. could you please help me write a complete instance code? thank you very much!

$conn = mysql_connect("127.0.0.1:8889","root","root"); $action = $_POST['action']; if($action == 'send'){   $test = join("','", $_POST['test']);   mysql_select_db("test3",$conn);   $sql = ("update tll set count=count+1 where tl01 in ('$test')");  $result = mysql_query($sql,$conn); }

$conn = mysql_connect("127.0.0.1:8889","root","root"); $action = $_POST['action']; if($action == 'send'){   $test = join("','", $_POST['test']);   mysql_select_db("test3",$conn);   $sql = ("update tll set count=count+1 where tl01 in ('$test')");  $result = mysql_query($sql,$conn); }

Great Gods have solved this problem! Thank you! Which book has learned this knowledge point? I want to see it again.

The format in the input box is incorrect, or the echo voting fails if the voting fails. how can this problem be solved?


$conn = mysql_connect("127.0.0.1:8889","root","root"); $action = $_POST['action']; if($action == 'send'){   $test = join("','", $_POST['test']);   mysql_select_db("test3",$conn);   $sql = ("update tll set count=count+1 where tl01 in ('$test')");  $result = mysql_query($sql,$conn); }

Great Gods have solved this problem! Thank you! Which book has learned this knowledge point? I want to see it again.

The format in the input box is incorrect, or the echo voting fails if the voting fails. how can this problem be solved?



I don't have to buy books. I have to check more information on the internet. it's mainly mysql-related knowledge. if you want to learn mysql syntax, you will.

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.