PHP循环时的HTML表单

Tav*_*ses 1 html php forms loops while-loop

如何将html表单放入PHP while循环中?

它认为是这样的,但它不起作用:

<?php

$i=1;
while ($i<=5){

<form name="X" action="thispage.php" method="POST">
     <input type="text">
     <input type="submit">
</form>;

$i=$i+1;

              }

?>
Run Code Online (Sandbox Code Playgroud)

Ric*_*der 5

你可以,就像那样在PHP中间不能有原始的HTML.在HTML之前结束PHP语句,然后像这样重新打开它:

 <?php

$i=1;
while ($i<=5){
?>

<form name="X" action="thispage.php" method="POST">
     <input type="text" name="trekking">
 <input type="submit">
</form>

<?php 
   $i=$i+1;
     }

?>
Run Code Online (Sandbox Code Playgroud)