How do I Batch input data and execute it? -Php Tutorial

Source: Internet
Author: User
How do I Batch input data and execute it? Dear friends, this is the case. I want to pass several pieces of data to adc. php one by one for execution. I know that the following code can be used to transmit a group of data. But what if I want to pass many groups without manual input in one group?

Script
$ (Document). ready (function (){
$ ("# Submit"). click (function (){
Var name = $ ("# name"). val ();
Var scores = $ ("# scores"). val ();
Location. href = "adc. php? Name = "+ name +" & scores = "+ scores;
}
Script






For example, if the following five groups of data are input five times separately, the above program is acceptable. however, is it possible for me to paste the following table into the text box at a time, and then the program will automatically identify and execute the data in groups one by one? Thank you.
Wang 100
Xiao Zhang 121
Liu 541
Zhang San 555
Li Si 410


Reply to discussion (solution)

The idea should be that the array json is passed to receive and parse the foreach loop

Yes. you can output all the names in a box and pass them directly to php with a uniform separator. then, you can use the string. splite () command on the front end.

For example, you entered: Xiao Wang 100 Xiao Zhang 121 Xiao Liu 541 Zhang San 555 Li Si 410 are separated by empty spaces.
Frontend processing

Var str = 'Wang 100 Xiao Zhang 121 Xiao Liu 541 Zhang San 555 Li Si 410 '; var data = str. splite (""); var urlparam = "? A = 1 "; // it is useless to pass multiple parameters to keep the data format convenient for the following loop (var I = 0; I
   
  
The backend obtains an array of names and scores.
Or you can directly pass it to the background
? Data = Xiao Wang 100 Xiao Zhang 121 Xiao Liu 541 Zhang San 555 Li Si 410
In the background, The explode () can also be cyclically based on the method similar to the above.

You can use textarea to save a row of users.
Then, PHP will explain it according to the line feed.

For example:
Html

   
     Submit     


Server. php
    $name,            'score' => $score        );    }}print_r($result);?>


In textarea, enter
Wang, 100
Zhang, 121
Liu, 541
Michael Zhang, 555
Li Si, 410

After submission, PHP obtains
Array ([0] => Array ([name] => John [score] => 100) [1] => Array ([name] => Xiao Zhang [score] => 121) [2] => Array ([name] => Xiao Liu [score] => 541) [3] => Array ([name] => Zhang San [score] => 555) [4] => Array ([name] => Li Si [score] => 410 ))

Thank you for your ideas and methods. I have not learned all about them, but I have learned about the second floor. Thank you.

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.