0

我创建了一个表格来显示搜索结果,表格的每一行都是一个链接,链接有一个隐藏的表单,带有一个 javascript 将 id 发送到另一个 php 页面,但问题是当我单击其中一个链接时,表单仅将第一个 id 发送到 sql 表。毕竟怎么了?

    while ($row = $stmt->fetch()) { 

        echo("<form id=id_form method=post action=lp_search_system_2.php>
        <input type=hidden name=id value=".$row['id_np_outdoor'].">
        </form>");

        echo '  <tr align="left" class="simple">
                    <td><a href="#" onclick="id_form.submit()">' . $row['nome'] . '</a></td>
                    <td><a href="#" onclick="id_form.submit()">' . $row['sobrenome'] . '</a></td>
                    <td><a href="#" onclick="id_form.submit()">' . $row['tipo'] . '</a></td>
                    <td><a href="#" onclick="id_form.submit()">' . $row['estado'] . '</a></td>
                    <td><a href="#" onclick="id_form.submit()">' . $row['país'] . '</a></td>
                </tr>

             ';

}
                echo "</table>";
4

1 回答 1

0
while ($row = $stmt->fetch()) {

    echo "<form id=id_form".$row['id or something'] method=post action=lp_search_system_2.php>";
    echo "<input type=hidden name=id value=".$row['id_np_outdoor'].">";
    echo "</form>";
    :
    :
    :
    as you have made it.

请记住,您还必须为每一行提交相应的表格。因此,也更改 onclick 代码..

于 2013-02-11T14:49:53.247 回答