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.