Club Delphi  
    FTP   CCD     Buscar   Trucos   Trabajo   Foros

Retroceder   Foros Club Delphi > Otros entornos y lenguajes > PHP
Registrarse FAQ Miembros Calendario Guía de estilo Temas de Hoy

Respuesta
 
Herramientas Buscar en Tema Desplegado
  #1  
Antiguo 24-01-2013
whitesnakevm whitesnakevm is offline
Miembro
NULL
 
Registrado: dic 2012
Posts: 12
Poder: 0
whitesnakevm Va por buen camino
Question 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>&nbsp;</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
Responder Con Cita
  #2  
Antiguo 24-01-2013
whitesnakevm whitesnakevm is offline
Miembro
NULL
 
Registrado: dic 2012
Posts: 12
Poder: 0
whitesnakevm Va por buen camino
aqui esta el php de conexion

Código PHP:
<?php
$conn 
mysql_connect("localhost","root","");

if (!
$conn){ 
    die(
"No se establecio conexion con el motor de base de datos");
}

$bd=mysql_select_db("empresa",$conn);

if(!
$bd){ 
    die(
"No se puede seleccionar la base de datos ");
}

?>
Responder Con Cita
Respuesta



Normas de Publicación
no Puedes crear nuevos temas
no Puedes responder a temas
no Puedes adjuntar archivos
no Puedes editar tus mensajes

El código vB está habilitado
Las caritas están habilitado
Código [IMG] está habilitado
Código HTML está deshabilitado
Saltar a Foro

Temas Similares
Tema Autor Foro Respuestas Último mensaje
Ayuda con este problema Suriu Varios 3 02-04-2012 13:46:41
Ayuda kn este programa :S llSnakell Varios 38 24-01-2011 10:54:58
Ayuda con este problema emiliano_b OOP 36 25-07-2010 03:36:27
ayuda con este codigo kurono Varios 4 13-06-2008 01:03:29
una ayuda con este error please dariana20 SQL 3 14-06-2006 23:14:06


La franja horaria es GMT +2. Ahora son las 09:03:59.


Powered by vBulletin® Version 3.6.8
Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Traducción al castellano por el equipo de moderadores del Club Delphi
Copyright 1996-2007 Club Delphi