Ver Mensaje Individual
  #3 (permalink)  
Antiguo 08/03/2013, 21:15
hardblues24
 
Fecha de Ingreso: febrero-2013
Mensajes: 10
Antigüedad: 11 años, 2 meses
Puntos: 0
Respuesta: mostrar campo en combobox y guardar otro campo de la consulta

<form name="form1" method="post" action="nueva.php">
<table width="200" border="1" align="center" class="stats">
<tr>
<td><label>
Orden a Ingresar:
</td>
<td>
<?
include('conex.php');
$sql = 'SELECT max(`idreparacion`) FROM `reparacion`';
$consul=mysql_query($sql,$svr);
$result=mysql_fetch_array($consul);
mysql_close($svr);
echo $result[0]+1;
?>
</tr>
<td>Cliente</td>
<td><label>

<select name="clientes" >
<?php
$conexion = mysql_connect ("localhost", "root", "")
or die ("No se puede conectar con el servidor");
mysql_select_db ("test")
or die ("No se puede seleccionar la base de datos");

$sql = "SELECT clientes.nombre as cliente,clientes.idcliente as id FROM clientes order by cliente";
$con = mysql_query($sql);
while($reg = mysql_fetch_assoc($con))
{
$client = $reg['cliente'];
$cliente=$_REQUEST['clientes'];
?>
<option>
<?php echo $client; ?>

</option>

<?php
}

?>
</select>

<a href="nuevocliente.php" target="_blank"><img src="cliente.jpg" alt="Agregar Cliente"></a>

</label></td>


</tr>
<tr>
<tr>
<td>Equipo a Reparar</td>
<td><label>
<input type="text" name="equipo" id="equipo">
</label></td>
</tr>

<td>Falla Declarada</td>
<td><label>
<textarea name="falla" id="falla" cols="45" rows="5"></textarea>
</label></td>
</tr>
<tr>
<td>&nbsp;</td>
<td><label>

<input type="submit" name="button" id="button" value="Enviar">


</label></td>
</tr>
</table>
</form>



</div>
<?
include('conex.php');
$falla=$_REQUEST['falla'];
$equipo=$_REQUEST['equipo'];
$cliente=$_REQUEST['clientes'];



if ($falla and $cliente){
$dia=getdate();
$dia= $dia[year].'-'.$dia[mon].'-'.$dia[mday];
//estado 0 = sin reparar
$sql = 'INSERT INTO `test`.`reparacion` (`falla`,`equipo`,`cliente`,`fechaing`,`estado`,`i dcliente`) VALUES ("'.$falla.'","'.$equipo.'","'.$cliente.'","'.$dia .'",0);';
$consul=mysql_query($sql,$svr);
echo '<script type="text/javascript">';
echo '</script>';
}
mysql_close($svr);
?>


este es el formulario como lo tengo actualmente pero lo que quiero es que cuando seleccione el cliente pueda guardar el idcliente y de esta manera hacer el insert para guardar el idcliente