将值发送到另一个页面

时间:2013-02-11 14:29:28

标签: php

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

    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>";

1 个答案:

答案 0 :(得分: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代码..