Update mediante formulario
| From: | Jonathan Rodriguez Martin | Date: | Tue, 28 May 2002 11:06:26 +0000 |
| Subject: | Update mediante formulario | ||
| Groups: | php.general.es | ||
| Request: | Send a blank email to general-es+get-23152@lists.php.net to get a copy of this message | ||
Mi consulta es la siguiente. Estoy haciendo un pequeno proyecto en el que como muestro aqui debajo tengo realizar una modificacion mediante un formulario. En el formulario me deben aparecer los datos que tengo en el registro seleccionado. Hasta ahi bien. pero cuando le doy otro valor en el formulario no me modifica pero si me sale el mensaje de registro modificado....Los siento por no explicarme mejor pero soy nuevo en esto y no tengo mucha idea. Gracias de Antemano
Nota: &box, &Id_type, &Id_status son enteros por lo que no debe llevar comillas no?
<?php
//Conectar con BD
$link = mysql_connect ("sevinal", "practice", "_practic_ando_");
mysql_select_db ("practice", $link);
//Modificar
if ($action == "M"){
?>
<u><title>Update Register</title></u>
<u><h1>Update Register</h1></u>
<table height = "300" width="1000">
<br><br>
<tr>
<td>
<u><h3 align = "top">Title</h3></u>
<FORM METHOD = "POST" action = "update.php">
<strong>Introduce Title of Cd:</strong> </td>
<?php
$result = mysql_query ("select Title from Title WHERE Id_title=$id", $link);
@$row = mysql_fetch_array ($result);
echo"<td><br><br><input type=\"text\" name=\"title\"value=\"" . $row['Title']. "\"size=\"20\"></td>"?> <br><br> <td> <u><h3>Comments</h3></u> <strong>Introduce word/s key:</strong></td> <?php
$result = mysql_query ("select Comments from Title WHERE Id_title=$id", $link);
@$row = mysql_fetch_array ($result);
echo"<td><br><textarea name=\"comments\">". $row['Comments']. "</textarea></td>";?> </tr> <tr> <td> <u><h3>Media</h3></u> <strong>Introduce Media:</strong></td> <?php $result = mysql_query ("select Media from Title WHERE Id_title=$id", $link); @$row = mysql_fetch_array ($result);
echo"<td><br><br><input type=\"text\"name=\"media\"value=\"" . $row['Media']. "\"size=\"20\"></td>";?> <td> <u><h3>Box</h3></u> <strong>Introduce number of box:</strong></td> <?php $result = mysql_query ("select Box from Title WHERE Id_title=$id", $link); @$row = mysql_fetch_array ($result); echo"<td><br><br><input type=\"text\"name=\"box\"value=\"" . $row['Box']. "\" size=\"20\"></td>"; ?> </tr> <tr> <td><u><h3>Status</h3></u></td> <td><SELECT NAME="Id_status" SIZE="1"> <?php $result = mysql_query ("SELECT Status From Status, Title WHERE Title.Id_status = Status.Id_status AND Id_title = $id", $link); $row = mysql_fetch_array ($result);
echo "<option value=\"" . $row[0] . "\">" . $row["Status"] . "</option>";$camb= mysql_query ("SELECT * FROM Status", $link);
while($cad = mysql_fetch_array ($camb)){
echo "<option value=\"" . $cad[0] . "\">" . $cad ["Status"] . "</option>";
}
?>
</SELECT></td>
<td><u><h3>Type</h3><u></td>
<td> <SELECT NAME="Id_type" SIZE="1">
<?php
$result = mysql_query ("SELECT Type FROM Type, Title WHERE Title.Id_type = Type.Id_type AND Id_title = $id", $link);
$row = mysql_fetch_array ($result);
echo "<option value=\"" . $row[0] . "\">" . $row["Type"] . "</option>";$camb= mysql_query ("SELECT * FROM Type", $link); while($cad = mysql_fetch_array ($camb)){ echo "<option value=\"" . $cad[0] . "\">" . $cad ["Type"] . "</option>"; } ?> </SELECT></td> </tr> </table> <br><br> <hr><hr> <input type="hidden" name="action" value="M"> <input type="submit" name="submit" value="Modificar"> </form> <br><br><br> <?php if ($submit=="Modificar"){ mysql_query("UPDATE Title set Title='$title', Comments ='$comments', Media='$media', Box=$box, Id_type=$Id_type, Id_status=$Id_status WHERE Id_title=$id", $link);
echo "Register Modified ";echo "<br><br><a href = \"buscar.php\"> New search </a><br><br>";
echo "<br><br>";exit; } } @mysql_free_result($result); @mysql_close($link); ?> _________________________________________________________________ MSN Photos es la manera más sencilla de compartir e imprimir sus fotos: http://photos.msn.com/support/worldwide.aspx