whitesnakevm |
24-01-2013 20:07:55 |
Problema con este formulario ayuda
No puedo guardar datos tampoco con el boton reestablecer , limpiar los campos de texto
ademas que en el 2° destino necesito elegir una ciudad y a traves de eso apretar el boton buscar y que abajo en el cuadro aparezca
todo los datos que necesito
Código PHP:
<?php include("conexion.php"); if (isset($_POST["btn_guar"])){ $num=$_POST["txt_num"]; $cho=$_POST["cmb_cho"]; $des=$_POST["cmb_des"]; $fecha=$_POST["txt_fech"]; $guardar="insert into Viaje values ('$num','$cho','$des','fecha')"; $sentencia=mysql_query($guardar,$conn); if(!$sentencia){ die("No se ha podido conectar, ERROR");} } ?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <title>Documento sin título</title> <?php $numero= ''; $nomcho = ''; $nomdes = ''; $fec = ''; $cos = '';
if (isset($_POST["btn_busc"])) { $numero=$_POST["txt_num"]; $consultar = "select * from Viaje where numero_via = '$txt_num'"; $sentencia = mysql_query($consultar,$conn); while($rs=mysql_fetch_array($sentencia,$bd)) { $numero= $rs["numero_via"]; $nomcho= $rs["nombre_cho"]; $nomdes= $rs["nombre_des"]; $fec= $rs["fecha_via"]; } }
?> </head>
<body><center><table width="332" height="167" border="1"> <tr> <td colspan="2"><div align="center">VIAJES DE MICROBUS</div></td> </tr> <tr> <td width="172" height="26">NUMERO DE VIAJE</td> <td width="144"><form id="form1" name="form1" method="post" action=""> <label for="txt_num"></label> <input type="text" name="txt_num" id="txt_num" /> </form></td> </tr> <tr> <td height="23"> CHOFER</td> <td><form id="cmb_cho" name="cmb_cho" method="post" action=""> <label for="cmb_cho"></label> <select name="cmb_cho" id="cmb_cho"> <?php $consulta = "select * from Chofer"; $listado = mysql_query($consulta,$conn);
while($rs=mysql_fetch_array($listado,$bd)) {
?> <option value="<?php echo $rs["codigo_chof"];?>" <?php if ($rs["codigo_chof"] == "") { echo "selected='selected'"; } ?> ><?php echo $rs["nombre_chof"];?></option> <?php } ?> </select> </form></td> </tr> <tr> <td height="23">DESTINO</td> <td><form id="form3" name="form3" method="post" action=""> <label for="cmb_des"></label> <select name="cmb_des" id="cmb_des"> <?php $consulta = "select * from Destino"; $listado = mysql_query($consulta,$conn);
while($rs=mysql_fetch_array($listado,$bd)) {
?> <option value="<?php echo $rs["codigo_des"];?>" <?php if ($rs["codigo_des"] == "") { echo "selected='selected'"; } ?> ><?php echo $rs["nombre_des"];?></option> <?php } ?> </select> </form></td> </tr> <tr> <td height="23">FECHA</td> <td><form id="form4" name="form4" method="post" action=""> <label for="txt_fech"></label> <input type="text" name="txt_fech" id="txt_fech" /> </form></td> </tr> <tr> <td height="23" colspan="2"><form id="form2" name="form2" method="post" action=""> <div align="center"> <input type="submit" name="btn_guar" id="btn_guar" value="GUARDAR" /> <input type="reset" name="btn_rest" id="button" value="REESTABLECER" /> </div> </form></td> </tr> <tr> <td height="23">DESTINO</td> <td><form id="form5" name="form5" method="post" action=""> <label for="btn_des2"></label> <select name="btn_des2" id="btn_des2"> <?php $consulta = "select * from Destino"; $listado = mysql_query($consulta,$conn);
while($rs=mysql_fetch_array($listado,$bd)) {
?> <option value="<?php echo $rs["codigo_des"];?>" <?php if ($rs["codigo_des"] == "") { echo "selected='selected'"; } ?> ><?php echo $rs["nombre_des"];?></option> <?php } ?> </select> <input type="submit" name="btn_busc" id="btn_busc" value="BUSCAR" /> </form></td> </tr> </table> <p> </p> <table width="534" height="61" border="1"> <tr> <td colspan="5"><div align="center">LISTA DE VIAJES</div></td> </tr> <tr> <td width="100">NUMERO </td> <td width="100">NOMBRE CHOFER</td> <td width="100">NOMBRE DESTINO</td> <td width="100">FECHA</td> <td width="100">COSTO</td> </tr> </table> </center>
</body> </html>
Espero que me ayuden
Saludos
|