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


How to update an element of the database depending the id, with a submit button

我有这样的代码,它将数据插入索引处的表中,但我如何使提交按钮modifystatus工作呢?我一直在尝试,但没有结果,目的是当我按下提交按钮"atendido"时,数据库列名状态的表将=0,这取决于更新的id

    <?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)); 
    } ?>

这是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'");
?>

您没有给出完整的逻辑,但更可能的是,您希望为输入使用特定的名称并更改值。例如:

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

然后值

$nombre = $_POST['nombre']

将包含名称。

为什么要使用:

$nombre = $_POST[$nombre];
$nombre = $_GET['nombre']; 

你只需要:

$nombre = $_POST[$nombre];

并停止使用mysql_。如果不推荐使用,请使用mysqli或PDO