首页 > 解决方案 > 在表单表引导程序中发布方法 PHP

问题描述

嗨,所有stackoverflow用户都直接放置基本方法,以便通过PHP中的method =“POST”将数据从一个页面传输到另一个页面:

表格.php:

<?php

session_start();

include '../connessione.php';

$id = $_SESSION['id'];

$query_string = "select * from ca2_2ac_clienti";

$query = mysqli_query($connessione, $query_string);

?>



<?php



while($row = mysqli_fetch_assoc($query)){ ?>

<form action="test.php" method="post">
    <input  name="text" value="<?php echo $row['id_cliente'] ;?>">
    <input type="submit" name="invia">
</form>

<?php } ?>

测试.php:

<?php $text = $_POST['text']; ?>

<form action="test.php" method="post">
    <input  name="text" value="<?php echo $text;?>">
    <input type="submit" name="invia">
</form>

到这里为止没问题,当我想在while循环内的表中实现它时,问题就出现了,即在我的表单中的值中我看不到任何类似的东西?

放置代码:

<?php

 while($row = mysqli_fetch_array($result))
 {
?>
                <!--Table body-->
                <tbody>
                    <tr>
                        <th scope="row">
                            <label class="form-check-label" for="checkbox1" class="label-table"></label>
                        </th>
                        <form action="test.php" method="post">
                        <td style="vertical-align: middle;">
                        <input  name="text" value="<?php echo $row['codice_impianto'] ;?>">
                        </td>

                        <a href="#modifica<?php echo $row['id_impianto']; ?>" data-toggle="modal" class="btn btn-sm btn-warning btn-rounded"><span class="glyphicon glyphicon-edit"></span> MODIFICA</a> 

                        <a href="#elimina<?php echo $row['id_impianto']; ?>" data-toggle="modal" class="btn btn-sm btn-danger btn-rounded"><span class="glyphicon glyphicon-trash"></span> ELIMINA</a>
                        <input type="submit" name="invia">
                        </form>

                        <?php include('modali.php'); ?>




                        </td>



                    </tr>


                </tbody>

  <?php
}
 }
else
{
 echo 'Nessun risultato corrisponde alla tua ricerca';
}

?>

标签: phpcsswhile-loop

解决方案


<form>元素不允许是<table>,<tr><tbody>元素的后代。您应该<form>在整个<table>元素周围放置


推荐阅读