每次更改选择输入时,我都试图更新数据库。我需要类似onchange之类的东西,此外,我还必须考虑该行的ID。有人可以帮助我吗?
我必须说我有一张包含更多信息的表,但我只是在问我需要更改的内容。
<?php
class conexion{
function recuperarDatos2(){
$host = "localhost";
$user = "root";
$pw = "xxxxxx";
$db = "almacen";
$con = mysql_connect ($host, $user, $pw) or die ("No se puedo conectar a la base de datos ");
mysql_select_db($db, $con) or die ("No se encontró lo que buscaba ");
$query = "SELECT * FROM pedidos ORDER BY ID ASC" ;
$resultado = mysql_query($query);
$numero = mysql_num_rows($resultado);
mysql_set_charset('utf8');
while ($fila = mysql_fetch_array($resultado)) {
echo "<tr>";
echo "
<input type='hidden' value=' $fila[ID] '>
<td>
<input id='ancho-series' type='text' class='form-control-sm' name='serie' placeholder=' $fila[serie] '>
// I should be able to write on this field and update the database
</td>
<td class='los_operarios'>
<select class='operarios' name='operario' >
</select>
// I should be able to change the value of this select and update the database
<span class='ope'> $fila[operario] </span>
//this is showing the $fila[operario] with a different color
</td>
<td class='mis_estados'>
<select id='ancho' class='estados' name='estado' >
</select>
// I should be able to change the value of this select and update the database
<span class='podemos'> $fila[estado]
</span>
//this is only showing the $fila[estado] with a different color
</td>
";
echo "</tr>";
}
}
}
?>