drus40229 2015-02-25 20:37
浏览 13
已采纳

如何使用提交按钮根据id更新数据库的元素

I have this code that inserts data into a table at index, but how can I make the submit button modifystatus work? I have been trying with no results, the aim is that when I press the submit button "atendido" the table of the database column name status will be = 0, depending the on id that is updating

    <?php if($total>0 && $search!='') 
    {
        do { 
             echo "<tr><form method='post' action='../solicitudes/modifystatusdown.php'>
             <td style='width:20%; '><input type='hidden' name='$fila[nombre]''><input type='text'>";
             echo $fila['nombre'];
             echo "</td><td style='width:20%;'>";
             echo $fila['telefono'];
             echo "</td><td style='width:20%;'>";
             echo "<input type='Submit' name='delete' value='Atendido'></td></form></tr>";
            } 
        while ($fila=mysqli_fetch_assoc($resultado)); 
    } ?>

this is the modifystatus.php

<?php

    $nombre = $_POST[$nombre];


    $nombre = $_GET['nombre']; 

    $link = mysql_connect("localhost","root","");
    if($link)
    {
        mysql_select_db("users",$link);
    }

    mysql_query("UPDATE usuarios SET status=0 WHERE nombre = '$nombre'");

?>
  • 写回答

2条回答 默认 最新

  • dongqian0763 2015-02-25 20:44
    关注

    You don't give your complete logic, but it is more likely that you want to use a specific name for your input and change the value. For example:

    <?php $nombre = $fila['nombre'] ?>
    <td style='width:20%; '>
        <input type='hidden' name='nombre' value='$nombre']'><input type='text'>";
    

    Then the value

    $nombre = $_POST['nombre']
    

    will contain the name.

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(1条)

报告相同问题?

悬赏问题

  • ¥100 求数学坐标画圆以及直线的算法
  • ¥100 c语言,请帮蒟蒻写一个题的范例作参考
  • ¥15 名为“Product”的列已属于此 DataTable
  • ¥15 安卓adb backup备份应用数据失败
  • ¥15 eclipse运行项目时遇到的问题
  • ¥15 关于#c##的问题:最近需要用CAT工具Trados进行一些开发
  • ¥15 南大pa1 小游戏没有界面,并且报了如下错误,尝试过换显卡驱动,但是好像不行
  • ¥15 自己瞎改改,结果现在又运行不了了
  • ¥15 链式存储应该如何解决
  • ¥15 没有证书,nginx怎么反向代理到只能接受https的公网网站