| |

VerySource

 Forgot password?
 Register
Search
View: 3191|Reply: 11

Ask the form array problem

[Copy link]

1

Threads

14

Posts

9.00

Credits

Newbie

Rank: 1

Credits
9.00

 China

Post time: 2020-11-19 09:00:01
| Show all posts |Read mode
while($r=mysql_fetch_array($result))
{
    $fid =$r["id"];
    $fname =$r["name"];
    $finfo =$r["info"];

echo "<tr><td align=\"right\" width=5%><input type=\"checkbox\" name=\"selforum[]\" value=\"$fid\" /></td>
      <td align=\"left\" width=20%><input type=\"text\" name=\"fname[]\" value=\"$fname\" size=\"20\" /></td>
      <td align=\"left\" width=65%><input type=\"text\" name=\"finfo[]\" value=\"$finfo\" size=\"60\" /></td>< /tr>";
}
echo "<tr><th colspan=\"3\">
      <a href=\"\"><input type=\"button\" value=\"新\" /></a>&nbsp;&nbsp;&nbsp;
      <a href=\"updateForum.php\"><input type=\"button\" value=\"Update\" /></a>&nbsp;&nbsp;&nbsp;
      <a href=\"delForum.php\"><input type=\"button\" value=\"delete\" onClick=\"check()\" /></a></th></tr>" ;
echo "</table>";


When clicking "update" "delete", how should this dynamically generated form be delivered????

When you click "New", a line is generated below <checkbox> <text> <text>, how to write this???
Reply

Use magic Report

0

Threads

4

Posts

3.00

Credits

Newbie

Rank: 1

Credits
3.00

 China

Post time: 2020-11-19 09:15:01
| Show all posts
Just like what you wrote on the page, you can get it by name.
Reply

Use magic Report

1

Threads

14

Posts

9.00

Credits

Newbie

Rank: 1

Credits
9.00

 China

 Author| Post time: 2020-11-19 10:30:01
| Show all posts
updateForum.php////////////////

for($i=0;$i<$selforum.length;$i++)
{
    if($selforum['$i'].checked)
    {
$forumid =$_POST[selforum['$i'].value"];
$forumname=$_POST[fname['$i']];
$foruminfo=$_POST[finfo['$i']];
   
Is this? But there is an error
Reply

Use magic Report

1

Threads

14

Posts

9.00

Credits

Newbie

Rank: 1

Credits
9.00

 Russia

 Author| Post time: 2020-11-19 10:45:01
| Show all posts
$forumid =$_POST[selforum['$i'].value];

The above is wrong
Reply

Use magic Report

0

Threads

4

Posts

3.00

Credits

Newbie

Rank: 1

Credits
3.00

 China

Post time: 2020-11-19 11:00:01
| Show all posts
$foruminfo=$_POST['finfo[]']; Get the array like this

Forgot whether to quote the quotes in $_POST[], his name is finfo[]
Reply

Use magic Report

1

Threads

14

Posts

9.00

Credits

Newbie

Rank: 1

Credits
9.00

 China

 Author| Post time: 2020-11-19 12:00:01
| Show all posts
$foruminfo=$_POST['finfo[]']; Get the array like this

===============

Thanks a lot, try
Reply

Use magic Report

1

Threads

14

Posts

9.00

Credits

Newbie

Rank: 1

Credits
9.00

 China

 Author| Post time: 2020-11-19 13:30:02
| Show all posts
$foruminfo=$_POST['finfo[]']; Get the array like this

Can not do it
Reply

Use magic Report

0

Threads

2

Posts

2.00

Credits

Newbie

Rank: 1

Credits
2.00

 China

Post time: 2020-11-19 13:45:01
| Show all posts
$foruminfo = $_POST["finfo"];
        $n = count($foruminfo);
        for($i=0;$i<$n;$i++) {
            echo $foruminfo$i];
        }
Reply

Use magic Report

0

Threads

2

Posts

2.00

Credits

Newbie

Rank: 1

Credits
2.00

 China

Post time: 2020-11-19 14:00:01
| Show all posts
Sorry, the echo $foruminfo$i] I sent above; dropped one [
Reply

Use magic Report

0

Threads

24

Posts

16.00

Credits

Newbie

Rank: 1

Credits
16.00

 China

Post time: 2020-11-19 14:15:01
| Show all posts
$i = 0;
while($r=mysql_fetch_array($result))
{
    $fid =$r["id"];
    $fname =$r["name"];
    $finfo =$r["info"];

echo "<tr><td align=\"right\" width=5%><input type=\"checkbox\" name=\"selforum[$i]\" value=\"$fid\" /></td>
      <td align=\"left\" width=20%><input type=\"text\" name=\"fname[$i]\" value=\"$fname\" size=\"20\" /></td >
      <td align=\"left\" width=65%><input type=\"text\" name=\"finfo[$i]\" value=\"$finfo\" size=\"60\" /></td ></tr>";
}


The program part can only be written in this way to distinguish each fname corresponding to its own finfo when receiving data
Otherwise it is impossible to determine which forum needs to be updated
Use $_POST['selforum'],$_POST['fname'],$_POST['finfo'] when receiving
Then foreach()
Reply

Use magic Report

You have to log in before you can reply Login | Register

Points Rules

Contact us|Archive|Mobile|CopyRight © 2008-2023|verysource.com ( 京ICP备17048824号-1 )

Quick Reply To Top Return to the list