Foros del Web » Programando para Internet » PHP »

importar datos

Estas en el tema de importar datos en el foro de PHP en Foros del Web. hola, tengo un formulario llamado formulario_tramiento.php, una base de datos llamada tecnoavicola19 y esta base hay una tabla llamada galpon. Como hago para que al ...
  #1 (permalink)  
Antiguo 30/08/2011, 21:40
 
Fecha de Ingreso: julio-2011
Ubicación: Popayán Cauca
Mensajes: 24
Antigüedad: 12 años, 8 meses
Puntos: 0
Información importar datos

hola, tengo un formulario llamado formulario_tramiento.php, una base de datos llamada tecnoavicola19 y esta base hay una tabla llamada galpon.
Como hago para que al abrir el formulario tratamiento me traiga en un select todos los lotes que se almacenan en la tabla galpon.
adjunto el codico del formulario tratamientos.
<html>
<head><title>FORMULARIOS DE TRATAMIENTOS</title>

<link rel="stylesheet" type="text/css" href="estilos/formscss.css">

<link rel="stylesheet" href="../herramientas/calendario/system.css" />
<script type="text/javascript" src="../herramientas/calendario/zapatec.js"></script>
<script type="text/javascript" src="../herramientas/calendario/calendar.js"></script>
<script type="text/javascript" src="../herramientas/calendario/calendar-es.js"></script>
</head>
<body bgcolor="">
<form name = "tratamientos" action="form_tratamientos.php" method="POST">

<table class="cuerpo8" align="center">
<tr>
<div class="titulo2">
<td><a href="formulario_lista_de_chequeo.php" >LISTA DE CHEQUEO</a></td>
<td><a href="formulario_lote.php" >INGRESO NUEVO LOTE</a></td>
<td><a href="formulario_costos1.php" >COSTOS</a></td>
<td><a href="formulario_tratamiento.php" >TRATAMIENTO</a></td>
<td><a href="formulario_produccion.php" >PRODUCCION</a></td>
<td><a href="formulario_ventas.php" >VENTAS</a></td></div>
<td><a href="formulario_galpon.php" >GALPON</a></td></div>
<td><a href="reporte.html" >REPORTE</a></td></div>
</tr>
</table>
<table align="center" cellspacing="0" cellpadding="0" >
<tr>
<td align="right" width"9%" height="100" valign="top" >
<IMG src="../imagenes/SENA_gif.gif" width="188" height="200"/>
</td>
<td align="left" valign="top">
<img src="../imagenes/logo4.png" width="781" height="200"/>
</td>
</tr>
</table>
<table class="cuerpo9" align="center" >
<tr class="titulo4">
<td align="center"colspan="4" ><MARQUEE><h2>FORMULARIO TRATAMIENTOS<h2></MARQUEE></td>
</tr>



<tr>

<td class ="titulo1">Identificación del lote</td>
<td>espacio donde apareceran los lotes</td>






</tr>


<tr>
<td class="titulo1">Identificación galpón</td>
<td ><select name="Galpon" class="campo" id="Galpon" style="width:120px" title='Seleccione el galpon' >
<option class="uno"> </option>
<option class="uno">galpon 1</option>
<option class="uno">galpon 2</option>
<option class="uno">galpon 3</option>
</select>

</td>

<td rowspan="6" colspan="2" align="center">
<textarea name="formula" rows="17" cols="90"></textarea></td>
</tr>

<tr>
<td class="titulo1">Clase de tratamiento</td>
<td ><select name="tratamientos" class=".select"id="tratamiento" style="width:120px" title='Seleccione el tratamiento' >
<option class="uno"></option>
<option class="uno">preventivo</option>
<option class="uno">correctivo</option>
<option class="uno">predictivo</option>

</select></td>
</tr>

<tr>
<td class="titulo1">Costo del tratamiento</td>
<td > <input name="costo" class="estilo_caja" type='text' size='13' title='costo'> </td>
</tr>

<tr>
<td class="titulo1">Fecha de inicio del tratamiento</td>
<td ><input id="fch_inicio" name="fch_inicio" class="estil_caja" type="text"size="13%" title='Fecha de inicio' readonly/>
<img id='btn_fch_inicio' title="Calendario para Seleccionar la Fecha de inicio" src='../herramientas/calendario/calendario_1.gif' border='0' style="cursor:pointer" ></td>


</tr>

<tr>
<td class="titulo1">Fecha de finalización del tratamiento</td>
<td ><input id="fch_final" name="fch_final" class="estil_caja" type="text"size="13%" title='Fecha de inicio' readonly/>
<img id='btn_fch_final' title="Calendario para Seleccionar la Fecha de inicio" src='../herramientas/calendario/calendario_1.gif' border='0' style="cursor:pointer" ></td>
<!--<td ><input id="fch_final" name="fch_final" class="estil_caja" type="text"size="13%" title='Fecha de finalizacion' readonly/>
<img id='btn_fch_final' title="Calendario para Seleccionar la Fecha de finalizacion" src='../herramientas/calendario/calendario_1.gif' border='0' style="cursor:pointer" ></td>-->
</tr>


</table>
<p align="center">


<input type='submit' name='boton' class='boton' value='Guardar'>
<input id="consulta" name="consulta" class='boton' type="button" value="Consultar" style='cursor:pointer' onClick="Ifr_reporte.location.href='ver_tratamient os.php';">
<input type="reset" name="boton2" class='boton' value="Cancelar" >
<input id="registro" name="salir" class='boton' type="button" value="Salir" style='cursor:pointer' onClick="location.href='base.html';">

</p>
<table width="100%" height="5%" border="1" align="center" cellspacing="1" cellpadding="1" >
<tr align='center'>
<td valign='top' >
<center>
<iframe name='Ifr_reporte' width='99%' height='300' align='center' frameborder='0' src='blanco.html'></iframe>
</center>
</td>
</tr>
</table>
</form>




<script type="text/javascript">
Zapatec.Calendar.setup({
weekNumbers : false,
showOthers : true,
showsTime : false,
step : 1,
electric : true,
inputField : "fch_final",
button : "btn_fch_final",
timeFormat : 24,
timeInterval : 05,
ifFormat : '%Y-%m-%d',
daFormat : '%Y-%m-%d'
});
</script>

<script type="text/javascript">
Zapatec.Calendar.setup({
weekNumbers : false,
showOthers : true,
showsTime : false,
step : 1,
electric : true,
inputField : "fch_inicio",
button : "btn_fch_inicio",
timeFormat : 24,
timeInterval : 05,
ifFormat : '%Y-%m-%d',
daFormat : '%Y-%m-%d'
});
</script>



</body>
</html>
  #2 (permalink)  
Antiguo 31/08/2011, 01:22
Avatar de fbedia88  
Fecha de Ingreso: enero-2011
Ubicación: Santander
Mensajes: 83
Antigüedad: 13 años, 3 meses
Puntos: 20
Respuesta: importar datos

tio... no tienes nada...

has de crear una conexion con la base de datos tal que asi:
Código PHP:
Ver original
  1. <?
  2.  
  3.     $mysql_host = "localhost";
  4.     $mysql_user = "Usuario";
  5.     $mysql_pass = "contr4s3na";
  6.     $mysql_bd = "nombre_bd";   
  7.    
  8. if (!($link=mysql_connect($mysql_host, $mysql_user, $mysql_pass)))
  9. {
  10.   echo "Error conectando a la base de datos.";
  11.   exit();
  12. }
  13. if (!mysql_select_db($mysql_bd, $link))
  14. {
  15.   echo "Error seleccionando la base de datos.";
  16.   exit();
  17. }
  18.  
  19. ?>
Lo mejor es meterlo en un fichero aparte y hacer arriba un include()

Luego en tu codigo tienes que hacer la consulta SQL para obtener los datos de tu BD y con un bucle cargarlos en el select que quieras o donde te apetezca...

Código PHP:
Ver original
  1. $sql = mysql_query("SELECT  campo, campo2... FROM tabla.... WHERE ....", $link);
  2.  
  3.    while ($row = mysql_fetch_array($sql)) {
  4.         echo "
  5.             <tr bgcolor='#cccccc' align='center'>
  6.                 <td><b>".$row[0]."</b></td>
  7.                 <td><b>".$row[1]."</b></td>
  8.                 <td><b>".$row[2]."</b></td>
  9.                 <td><b>".$row[3]."</b></td>
  10.             </tr>
  11.         ";
  12.     }

bueno.. es solo un ejemplo... tienes que esforzarte un poco mas en ese codigo
__________________
URGENTE! Alguien me puede ayudar con este tema??
http://www.forosdelweb.com/f57/tarea...rontab-924947/

Etiquetas: html, registro, tabla, formulario
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 18:18.