Código HTML:
<?php include("conexiobd.php"); // realizo la consulta $q="select * from producto order by nombre asc"; $rs=mysql_query($q,$con); //al presionar el boton BUSCAR, tomo valor de COD if(isset($_POST['buscar'])) { $cod=$_POST['cod']; $q1="select * from producto where(cod_producto='$cod')"; $rs1=mysql_query($q1,$con); // recupero valores de los caompos de la BD de acuerdo al COD $r1=mysql_fetch_array($rs1); $cod=$r1['cod_producto']; $nom=$r1['nombre']; $des=$r1['descripcion']; $cat=$r1['categoria']; $uni=$r1['unidad']; } ?> <!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>Registro de Entradas</title> <link href="estilo_ingreso.css" rel="stylesheet" type="text/css" /> </head> <body> <table width="480" border="2" align="center" cellpadding="0" cellspacing="0" bordercolor="#039" style="border-collapse:collapse"> <tr> <td><form action="" method="post" enctype="multipart/form-data" name="form1" id="form1"> <table width="100%" border="0" cellspacing="0" cellpadding="5"> <tr> <td colspan="2" align="center" class="titulocentro">REGISTRO DE INGRESO DE PRODUCTOS</td> </tr> <tr> <td class="texto1">CODIGO PRODUCTO:</td> <td> // AQUI ESTA MI "LISTA/MENU" <select name="cod" id="cod"> <option selected="selected">Seleccione.... </option> <?php while($r=mysql_fetch_array($rs)) { ?> <option value="<?php echo $r['cod_producto']; ?>"><?php echo $r['cod_producto']; ?> </option> <?php } ?> </select> <input type="submit" name="buscar" id="buscar" value="Enviar" /></td> </tr> <tr> <td class="texto1">NOMBRE PRODUCTO:</td> <td><input name="nom" type="text" id="nom" value="<?php echo $nom; ?>" size="48" /></td> </tr> <tr> <td class="texto1"><label for="textarea"></label> <textarea name="textarea" id="textarea" cols="45" rows="5"><?php echo "DESCRIPCION:"." ".$des; ?></textarea></td> <tr> <td class="texto1">CATEGORIA:</td> <td><input type="text" name="cat" id="cat" value="<?php echo $cat; ?>" /></td> </tr> <tr> <td class="texto1">UNIDAD:</td> <td><input type="text" name="uni" id="uni" value="<?php echo $uni; ?>" /></td> //CAMPO OCULTO DEL VALOR --> COD <input type="hidden" name="cod_prod" id="cod_prod" value="<?php echo $cod; ?>" /></td> </tr> </table> </form></td> </tr> </table> </body> </html>
PERO EL PROBLEMA ES: que cuando selecciono un código de la lista y presiono el botón "BUSCAR" me muestra sus datos correctamente, pero el detalle esta en que en mi LISTA/MENU se pierde el VALOR que eh seleccionado ese es el problema, como hago para que no se pierda ese valor???
AYUDA POR FAVOR no se que le puedo aumentar al codigo, o de que forma hago una busqueda ayuda porfa!!