Ver Mensaje Individual
  #1 (permalink)  
Antiguo 09/03/2014, 16:15
jackfranco18
 
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]')"
);
            }

?>