Hola amigos nuevamente molestandolos tengo el siguiente problema no puedo actualizar mis registros a la base de datos:
1.- Primero hago una busqueda de los registros como lo ven aqui:
<?php
include "cnximp.php";
if (isset($_POST['b_buscarimp'])) {
mysql_real_escape_string($_POST['imp_rubros']);
if ($_POST[imp_rubros]=='modelo') {
$query=mysql_query("select * from impresoras
inner join marcas on impresoras.idMar = Marcas.idMar
where Modeloimp = '$_POST[c_buscarimp]'");
echo "<table border=\"1\" bordercolor=\"#000000\">";
echo "<tr>";
echo "<td align=\"center\" class=\"encabezado\">ID</td>";
echo "<td align=\"center\" class=\"encabezado\">Modelo</td>";
echo "<td align=\"center\" class=\"encabezado\">Hora</td>";
echo "<td align=\"center\" class=\"encabezado\">Tipo</td>";
echo "<td align=\"center\" class=\"encabezado\">Marca</td>";
echo "<td align=\"center\" class=\"encabezado\">Fecha</td>";
echo "<td align=\"center\" class=\"encabezado\">Serie</td>";
echo "<td align=\"center\" class=\"encabezado\">Area</td>";
echo "<td align=\"center\" class=\"encabezado\">Ubicacion</td>";
echo "</tr>";
while ($reg=mysql_fetch_array($query)) {
echo "<tr>";
echo "<td>$reg[idImp]</td>";
echo "<td>$reg[Modeloimp]</td>";
echo "<td>$reg[Horimp]</td>";
echo "<td>$reg[Tipoimp]</td>";
echo "<td>$reg[Descmar]</td>";
echo "<td>$reg[Fechimp]</td>";
echo "<td>$reg[Serieimp]</td>";
echo "<td>$reg[areaimp]</td>";
echo "<td>$reg[ubicimp]</td>";
echo "</tr>";
}
echo "</table>";
}
}
if (isset($_POST['b_buscarimp'])) {
mysql_real_escape_string($_POST['imp_rubros']);
if ($_POST[imp_rubros]=='serie') {
$query=mysql_query("select * from impresoras
inner join marcas on impresoras.idMar = Marcas.idMar
where Serieimp = '$_POST[c_buscarimp]'");
echo "<table border=\"1\" bordercolor=\"#000000\">";
echo "<tr>";
echo "<td align=\"center\" class=\"encabezado\">ID</td>";
echo "<td align=\"center\" class=\"encabezado\">Serie</td>";
echo "<td align=\"center\" class=\"encabezado\">Hora</td>";
echo "<td align=\"center\" class=\"encabezado\">Tipo</td>";
echo "<td align=\"center\" class=\"encabezado\">Marca</td>";
echo "<td align=\"center\" class=\"encabezado\">Modelo</td>";
echo "<td align=\"center\" class=\"encabezado\">Fecha</td>";
echo "<td align=\"center\" class=\"encabezado\">Area</td>";
echo "<td align=\"center\" class=\"encabezado\">Ubicacion</td>";
echo "</tr>";
while ($reg=mysql_fetch_array($query)) {
echo "<tr>";
echo "<td>$reg[idImp]</td>";
echo "<td>$reg[Serieimp]</td>";
echo "<td>$reg[Horimp]</td>";
echo "<td>$reg[Tipoimp]</td>";
echo "<td>$reg[Descmar]</td>";
echo "<td>$reg[Modeloimp]</td>";
echo "<td>$reg[Fechimp]</td>";
echo "<td>$reg[areaimp]</td>";
echo "<td>$reg[ubicimp]</td>";
echo "</tr>";
}
echo "</table>";
}
}
?>
<form id="form1" name="form1" method="post" action="modifimpresoras.php">
<label>
<select name="ids">
<option></option>
<option value="id">ID</option>
</select>
</label>
<label>
<input name="c_buscarimp" type="text" />
</label>
<label>
<input name="b_modimp" type="submit" value="Modificar"/>
</label>
</form>
[B]
2.- Selecciono el registro que quiero modificar como se ve aqui:/B]
<?php
include "cnximp.php";
mysql_real_escape_string($_POST['ids']);
if ($_POST[ids]=='id') {
$query=mysql_query("select * from impresoras
inner join marcas on impresoras.idMar = Marcas.idMar
where idImp = '$_POST[c_buscarimp]'");
$reg=mysql_fetch_array($query);
}
?>
<body>
<div id="contenedor">
<div id="cabecera">
<h1 align="center"><img src="imagenes/itesm_azul.jpg" alt="tecnologico" width="251" height="93" /></h1>
</div>
<div id="columna1">
<p>.</p>
</div>
<div id="columna2">
<h2 align="center">Modificacion de Impresoras </h2>
<p align="center"> </p>
<table width="524" border="0" align="center">
<tr>
<td><form name="frmmodificacionimp" method="post" action="" class="fondo">
<table width="133" border="0">
<tr>
<td>ID
<label>
<input name="cm_id" type="text" value="<?php echo "$reg[idImp]"; ?>" size="3" readonly="yes" />
</label></td>
</tr>
</table>
<table width="275" border="0" align="center">
<tr>
<td>Fecha
<label>
<input name="cm_fechaimp" type="text" id="cm_fechaimp" value="<?php echo date ("j-m-y"); ?>" size="8" readonly="yes" />
</label></td>
<td>Hora
<label>
<input name="cm_horaimp" type="text" value="<?php echo date ("h:i:s"); ?>" size="8" readonly="yes" />
</label></td>
</tr>
</table>
<table width="200" border="0" align="center">
<tr>
<td>Tipo
<label>
<select name="cm_tiposimp">
<option value="tipoimpresora"><?php echo "$reg[Tipoimp]"; ?> </option>
<option value="deskjet">Deskjet</option>
<option value="fax">Fax</option>
<option value="inyeccion tinta">Inyeccion de tinta</option>
<option value="laser">Laser</option>
</select>
</label></td>
<td>Marca
<label>
<select name="cm_marcasimp">
<option value="<?php "$reg[Descmar]"; ?>;"><?php echo "$reg[Descmar]"; ?></option>
<?php
include("cnximp.php");
$query=mysql_query("SELECT * FROM marcas");
while ($result=mysql_fetch_array($query)) {
echo "<option value=\"$result[idMar]\">$result[Descmar]</option>";
}
?>
</select>
</label></td>
<td>Modelo
<label>
<input name="cm_modimp" type="text" value="<?php echo "$reg[Modeloimp]"; ?>"/>
</label></td>
</tr>
</table>
<table width="383" border="0" align="center">
<tr>
<td>Serie
<label>
<input name="cm_serieimp" type="text" value="<?php echo "$reg[Serieimp]" ?> " />
</label></td>
<td>Area
<label>
<select name="cm_areasimp" onchange="ubicacionesimp()">
<option value=""><?php echo "$reg[areaimp]"; ?></option>
<option value="Biblioteca preparatoria">Biblioteca preparatoria</option>
<option value="Direccion preparatoria">Direccion preparatoria</option>
<option value="Direccion de area bicultural">Direccion de area bicultural</option>
<option value="Direccion de ciencias">Direccion de ciencias</option>
<option value="Direccion lenguaje y comunicacion">Direccion lenguaje y comunicacion</option>
<option value="Matematicas">Matematicas</option>
<option value="Idiomas">Idiomas</option>
<option value="Sala de profesores preparatoria">Sala de profesores preparatoria</option>
<option value="Orientacion y prevencion">Orientacion y prevencion</option>
<option value="Rectoria">Rectoria</option>
<option value="Arquitectos">Arquitectos</option>
<option value="Legal">Legal</option>
<option value="Diseñadores">Diseñadores</option>
<option value="Nominas">Nominas</option>
<option value="DAE">DAE</option>
</select>
</label></td>
<td>Ubicacion
<label>
<input name="cm_ubicimp" type="text" value="<?php echo "$reg[ubicimp]" ?> "/>
</label></td>
</tr>
</table>
<p> </p>
<p> </p>
</form>
</td>
</tr>
</table>
<table width="155" border="0" align="center">
<tr>
<td width="76"><form id="form1" name="form1" method="post" action="buscarimpresoras.php">
<label>
<input name="b_regresar" type="submit" value="Regresar" />
</label>
</form>
</td>
<td width="89"><form name="form2" method="post" action="guardarmodimp.php">
<label>
<input name="b_guardar" type="submit" value="Guardar" />
</label>
</form>
</td>
</tr>
</table>
</body>
</html>
3.- Actualizo el registro el problema es que me manda error y no actualiza ningun registro
<?php
$reg=mysql_query("select * from impresoras");
while ($regimp=mysql_fetch_array($reg)) {
if ($_REQUEST['cm_id']==$regimp['idImp']) {
mysql_query("update impresoras set Fechimp = '$_REQUEST[cm_fechaimp]'
where idImp = '$_REQUEST[cm_id]'");
echo "<h2>Los datos se actualizaron correctamente </h2>";
}
else {
echo "<h2>Error </h2>";
}
}
?>