PHP multiple button return values-php Tutorial

Source: Internet
Author: User
The problem of returning values of multiple buttons in PHP reads the name in the txt text cyclically, and adds a button after each name. The trouble is how to set the return value of the button and how to match the name with the button one by one.


It doesn't matter if the value is set to the same, but it doesn't seem to work if you use the previous variable to assign values to the returned value name.


Reply to discussion (solution)

Add the previous name and paste your code.

Add the previous name and paste your code.
$ Logi = file ("./data/list.txt ");
$ Size = sizeof ($ Logi );
Foreach ($ Logi as $ Key => $ Val)
{$ Data [$ Key] = explode ("|", $ Val );
}
$ K = 0;
$ Num = $ Data [$ K] [0];
For (; $ K <$ size ;)
{
$ Num = $ Data [$ K] [0];
If ($ num ){
$ Title = $ Data [$ K] [1];
Echo $ title;
?>

$ K ++;
}
}
The entity is like this. The txt format is 1 | xxx
2 | yyy

I suggest you paste the code. you may not understand the meaning of the code...


Loop through the submit button and write the name as a variable

Yes. I don't know the format of your txt text. Below is a loop to read the txt file name under a directory.

foreach(glob('*.txt') as $filename){     echo '

';}


Loop through the submit button and write the name as a variable
Can I write down the code?

$Logi=file("./data/list.txt");$size=sizeof ($Logi); foreach( $Logi as $Key => $Val ) { $Data [ $Key ] = explode ( "|" , $Val ); } $K=0;$num=$Data [ $K ][ 0 ];?>  

Check the code.

You are working on the submit button. What are you going to do after submitting?

This should be well written.

You are working on the submit button. What are you going to do after submitting?
After submission, you can enter a uniform page to write comments. However, I need to determine which name is and record it under the file with that name.

That is to say, you only need to know the yyy in 2 | yyy, right?
Then your #2 code should be written

$ Logi = file (". /data/list.txt ", FILE_IGNORE_NEW_LINES); // The parameter is used to remove the linefeed foreach ($ Logi as $ Key => $ Val) {list ($ num, $ title) = explode ("|", $ Val); if ($ num) {echo $ title;?>
 In the accepted Program
$ Title = key ($ _ GET); // The Input name is obtained.

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.