Foros del Web » Programando para Internet » PHP »

[SOLUCIONADO] PHP OO combobox dependiente que ingresa id y quisiera que ingrese las opciones que aparece

Estas en el tema de combobox dependiente que ingresa id y quisiera que ingrese las opciones que aparece en el foro de PHP en Foros del Web. amigos del forodelweb cesecito su ayuda urgente lo que pasa es que mi combobox dependientes me esta insertando los id y no los nombres que ...
  #1 (permalink)  
Antiguo 09/03/2014, 16:15
 
Fecha de Ingreso: marzo-2014
Mensajes: 20
Antigüedad: 10 años, 1 mes
Puntos: 0
Pregunta combobox dependiente que ingresa id y quisiera que ingrese las opciones que aparece

amigos del forodelweb cesecito su ayuda urgente lo que pasa es que mi combobox dependientes me esta insertando los id y no los nombres que aparecen como opciones. les agradeceria que me ayuden llevo dias con este problea

Código PHP:
<?php 
session_start
();
mysql_connect("localhost","root","telesup") or die("No se puede conectar");
mysql_select_db("madi") or die ("No se ha podido seleccionar la Base de Datos");
//Recuperacion de las variables convertidas en sesiones
$mercaderista=$_SESSION['mercaderista2']=@$_REQUEST['mercaderista']; 
$tienda=$_SESSION['tienda2']=@$_REQUEST['tienda'];
$cliente=$_SESSION['cliente2']=@$_REQUEST['cliente'];
$categoria=$_SESSION['categoria2']=@$_REQUEST['categoria'];
$producto=$_SESSION['producto2']=@$_REQUEST['producto'];

//QUERY COMBO 1
$query="select * from mercaderista"
$res=mysql_query($query);

//QUERY COMBO 2
$query2="select * from tienda WHERE id_mercaderista=$mercaderista"
$res2=mysql_query($query2);

//QUERY COMBO 3
$query3="select * from cliente1 WHERE id_tienda=$tienda";
$res3=mysql_query($query3);

//QUERY COMBO 4
$query4="select * from categoria1 WHERE id_cliente=$cliente"
$res4=mysql_query($query4);

//QUERY COMBO 5
$query5="select * from producto1 WHERE id_categoria=$categoria"
$res5=mysql_query($query5);


//Consultas para imprimir los resultados en la ultima parte del programa


$selectS="select nombre_mercaderista from mercaderista where id_mercaderista=$mercaderista";
$resS2=mysql_query($selectS);
$rowS2=@mysql_fetch_assoc($resS2); 


$selectS3="select nombre_tienda from tienda where id_mercaderista=$mercaderista and id_tienda=$tienda";
$resS3=mysql_query($selectS3);
$rowS3=@mysql_fetch_assoc($resS3); 

$selectS4="select nombre_cliente from cliente1 where id_tienda=$tienda and id_cliente=$cliente";
$resS4=mysql_query($selectS4);
$rowS4=@mysql_fetch_assoc($resS4); 


$selectS5="select nombre_categoria from categoria1 where id_cliente=$cliente and id_categoria=$categoria";
$resS5=mysql_query($selectS5);
$rowS5=@mysql_fetch_assoc($resS5); 

$selectS6="select nombre_producto from producto1 where id_categoria=$categoria and id_producto=$producto";
$resS6=mysql_query($selectS6);
$rowS6=@mysql_fetch_assoc($resS6);
?>



<!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>
</head>
<body>
<h1 align="center">reporte de mercaderista</h1>
<form method="POST" action="formulario.php" >
<TABLE align="center">
  <TR> 
  <TR>
  <TD>fecha</TD>   
  <TD><?php // m/d/Y H:i:s otra opcion de fecha y hora 
$fecha time();

echo 
date("d-m-y (h:i:s)"$fecha);

?></TD>
  </TR>
  <TD width="155">mercaderista</TD>
  <TD width="158"zz><select name="mercaderista" onchange="this.form.submit()" style="width: 270px" >
<option value="<?php echo $mercaderista?>" >
<?php echo $rowS2['nombre_mercaderista']?>
</option>
<?php while($row=mysql_fetch_array($res)){?>
<option value="<?php echo $row['id_mercaderista']?>">
<?php echo htmlentities($row['nombre_mercaderista']);?>
</option>
<?php }?>
</select></TD> 
  </TR> 
  <TR>
  <TD>tienda</TD>
  <TD><select name="tienda" style="width: 270px" onchange="this.form.submit()">
<option value="<?php echo $tienda?>">
<?php echo $rowS3['nombre_tienda'?>
</option>
<?php while($row2=mysql_fetch_array($res2)){?>
<option value="<?php echo $row2['id_tienda']?>">
<?php echo htmlentities($row2['nombre_tienda']);?>
</option>
<?php ?>
</select></TD>
  </TR>
  <TR>
  <TD>cliente</TD>
  <TD><select name="cliente" onchange="this.form.submit()" style="width: 270px">
<option value="<?php echo $cliente?>">
<?php echo $rowS4['nombre_cliente'?>
</option>
<?php while($row3=mysql_fetch_array($res3)){?>
<option value="<?php echo $row3['id_cliente']?>">
<?php echo htmlentities($row3['nombre_cliente']);?>
</option>
<?php ?>
</select></TD>
  </TR>
  <TR>
  <TD>categoria</TD>
  <TD><select name="categoria" onchange="this.form.submit()" style="width: 270px">
<option value="<?php echo $categoria?>">
<?php echo $rowS5['nombre_categoria'?>
</option>
<?php while($row4=mysql_fetch_array($res4)){?>
<option value="<?php echo $row4['id_categoria']?>">
<?php echo htmlentities($row4['nombre_categoria']);?>
</option>
<?php ?>
</select></TD>
  </TR>
  <TR>
  <TD>producto</TD>
  <TD><select name="producto" onchange="this.form.submit()" style="width: 270px">
<option value="<?php echo $producto?>">
<?php echo $rowS6['nombre_producto'?>
</option>
<?php while($row5=mysql_fetch_array($res5)){?>
<option value="<?php echo $row5['id_producto']?>">
<?php echo htmlentities($row5['nombre_producto']);?>
</option>
<?php ?>
</select></TD>
  </TR>
  <TR>
  <TD>stock en gondola</TD>
  <TD><input type="int" name="s_gondola" size="10" maxlength="30" />
  und</TD>
  </TR>
  <TR>
  <TD>stock en almacen</TD>
  <TD><input type="int" name="s_almacen" size="10" maxlength="30" />
  und</TD>
  </TR>
  <TR>
  <TD>cantidad a vencer </TD>
  <TD><input type="int" name="c_vencer" size="10" maxlength="30" />
  und</TD>
  </TR>
  <TR>
  <TD colspan="2" align="center"><INPUT TYPE="submit" name="guardar" VALUE="insertar reporte" ></TD>
  </TR>
 </TABLE></FORM>
 
 <center>
 <p>
 <a href="<?php echo $logoutAction ?>">cerrar session</a> </p>
 </center>
</body>
</html>

<?php
mysql_connect
('localhost','root','telesup') ;
            
mysql_select_db('madi') or die(mysql_error());
            if (@
$_POST['guardar'])
            {
                
            
mysql_query("insert into reporte(
            fecha, 
         mercaderista,
         tienda,
         cliente,
         categoria,
         producto,
         s_gondola,
         s_almacen,
         c_vencer)
values
      (now(),
      '$mercaderista',
      '$tienda',
      '$cliente',
      '$categoria',
       '$producto',
      '$_POST[s_gondola]',
      '$_POST[s_almacen]',
     '$_POST[c_vencer]')"
);
            }

?>
  #2 (permalink)  
Antiguo 10/03/2014, 07:57
Avatar de enlinea777  
Fecha de Ingreso: mayo-2008
Ubicación: frente al pc
Mensajes: 1.830
Antigüedad: 15 años, 11 meses
Puntos: 127
Respuesta: combobox dependiente que ingresa id y quisiera que ingrese las opciones qu

en value del <option tiene que llevar el nombre no el id, asi ingresaras el nombre al enviarlo.

para cambiar la dependencia usa una busqueda por el nombre no por el id
  #3 (permalink)  
Antiguo 10/03/2014, 11:36
 
Fecha de Ingreso: marzo-2014
Mensajes: 20
Antigüedad: 10 años, 1 mes
Puntos: 0
Respuesta: combobox dependiente que ingresa id y quisiera que ingrese las opciones qu

ejemplo porfavor...... :(
  #4 (permalink)  
Antiguo 10/03/2014, 11:37
 
Fecha de Ingreso: marzo-2014
Mensajes: 20
Antigüedad: 10 años, 1 mes
Puntos: 0
Respuesta: combobox dependiente que ingresa id y quisiera que ingrese las opciones qu

ya intente y me sale en blanco o numero :C

Etiquetas: html
Atención: Estás leyendo un tema que no tiene actividad desde hace más de 6 MESES, te recomendamos abrir un Nuevo tema en lugar de responder al actual.
Respuesta




La zona horaria es GMT -6. Ahora son las 12:43.