Foros del Web » Programando para Internet » PHP »

Por favor: necesito un ejemplo escrito

Estas en el tema de Por favor: necesito un ejemplo escrito en el foro de PHP en Foros del Web. Hola a todos. Hace ya un tiempo que espuse un problema que tenía con un par de páginas. Lo intentaré explicar para ver si me ...
  #1 (permalink)  
Antiguo 25/10/2009, 06:47
 
Fecha de Ingreso: septiembre-2002
Mensajes: 153
Antigüedad: 21 años, 7 meses
Puntos: 1
Por favor: necesito un ejemplo escrito

Hola a todos.

Hace ya un tiempo que espuse un problema que tenía con un par de páginas.

Lo intentaré explicar para ver si me lo podían explicar con un ejemplo escrito... ya no sé que más hacer (llevo más de tres semanas con el código).

El tema es el siguiente:

Necesito hacer dos páginas:

1 - En la primera, tiene que haber dos listas desplegables. En la primera lista, se elige un nombre de fabricante. Al hacerlo, en la segunda lista desplegable deben aparecer los artículos a los que está vinculado, y se debe seleccionar uno de ellos.

Y un botón de "Enviar".

Al dar a "Enviar", nos manda a la segunda página donde, en un campo de texto mostrará el nombre del fabricante y, en otro campo de texto, el artículo seleccionado.

Más abajo, otro campo de texto donde se debe escribir un texto identificativo del producto, y otro campo de texto para introducir el precio.

Botón de "Enviar".

2 - La primera página ya la tengo hecha desde el principio, pero al dar a "Enviar" y abrirme la segunda página, me manda los datos directamente, sin dejarme escribir el texto identificativo ni el precio... de hecho, ni me muestra los campos de texto.

En la base de datos sólo me graba el ID del fabricante y el ID del producto elegido.

Los campos de texto identificativo y el del precio los deja a cero.

Doy por hecho que el fallo está en el código, ya que le dá igual que el campo de texto del texto identificativo ni el del precio estén vacios.

Les agradecería cualquier ayuda, ya que el código de otras páginas que ya había echo con anterioridad no me sirve y ya no sé por donde tirar.

Muchas gracias de antemano y un saludo a todos:

Javy
  #2 (permalink)  
Antiguo 25/10/2009, 07:06
Avatar de AnesGy  
Fecha de Ingreso: mayo-2009
Mensajes: 518
Antigüedad: 15 años
Puntos: 19
Respuesta: Por favor: necesito un ejemplo escrito

Si el código es el error, entonces deberías mirar el código, o al menos enseñarlo.
__________________
Si alguna vez parece que soy grosero, pido perdón, es un intento fallido de ser directo.

AnesGy SD. Name it, Get it
  #3 (permalink)  
Antiguo 26/10/2009, 07:08
 
Fecha de Ingreso: septiembre-2002
Mensajes: 153
Antigüedad: 21 años, 7 meses
Puntos: 1
Respuesta: Por favor: necesito un ejemplo escrito

Tienes razón "ANESGY".

Aquí pongo el código de la segunda página:

<html>
<head>
<META HTTP-EQUIV="Content-Type" content="text/html; charset=utf-8">
</head>
<body>
<?php
//CONECTANDO CON LA BASE DE DATOS
require_once("../incluye/config_javy.php");
require_once("../incluye/funciones.php");
//CONECTAR A LA BASE DE DATOS
$cnx = conectar ();

//SI EL FORMULARIO HA SIDO ENVIADO, SE EDITA EL REGISTRO
if(isset($_POST['submit'])){

$sql = "INSERT INTO tipoimpresoras SET fabimpid ='".$_POST['fabimpid']."', numerocartuchoid ='".$_POST['numerocartuchoid']."', textotipoimp ='$textotipoimp', textopreciocartucho ='$textopreciocartucho'";


$res = mysql_query($sql) or die(mysql_error());
echo "Registro actualizado.<br><br><form action='tipoimpresoras.php' method='post'><input name='entrar' type='submit' id='entrar' value='REGRESAR' onClick='submit()' /></form>";
mysql_close($idcnx);
exit;
}



//CONECTANDO CON LA BASE DE DATOS
require_once("../incluye/config_javy.php");
require_once("../incluye/funciones.php");

//CONECTAR A LA BASE DE DATOS
$cnx = conectar ();
?>
<table border="1" cellpadding="0" cellspacing="0">
<form enctype="multipart/form-data" name="form1" method="post" action="<? echo $PHP_SELF;?>">
<tr>
<td colspan="2">
<?php
$fabimpid;
$numerocartuchoid;
mysql_select_db($DATABASE, $idcnx);
?>
<table>
<tr>
<td>Fabricante de Impresora:</td>
<?php
$cnx = conectar ();
$select = "SELECT DISTINCT numerocartuchoid, numerocartucho.fabimpid, textonumerocartucho, fabimpresoras.fabimpid, textofabimp";
$from = " FROM numerocartucho, fabimpresoras";
$where = " WHERE numerocartuchoid > 0 AND fabimpresoras.fabimpid = numerocartucho.fabimpid";
if ($fabimpid > 0) {
// HAY UN FABRICANTE DE IMPRESORAS
$where .= " AND fabimpresoras.fabimpid=$fabimpid";
}
if ($numerocartuchoid > 0) {
// HAY UN NÚMERO DE CARTUCHO
$where .= " AND numerocartuchoid=$numerocartuchoid";
}
$bus = mysql_query($select . $from . $where);
if( mysql_num_rows($bus) >0){
while ($bu = mysql_fetch_array($bus)){
$textofab = $bu["textofabimp"];
$textonumerocar = $bu["textonumerocartucho"];
?>
<td><input name="textofabimp" type="text" value="<?echo $textofab;?>" size="40">
<input type="hidden" name="fabimpid" value="<?echo $fabimpid;?>"></td>
<tr>
<tr>
<td>Número de Cartucho:</td>
<td><input name="textonumerocartucho" type="text" value="<?echo $textonumerocar;?>" size="40">
<input type="hidden" name="numerocartuchoid" value="<?echo $numerocartuchoid;?>"></td>
<?php
}// CIERRES DE LAS LINEAS 82 Y 83
}
?>
</tr>
</table></td>
</tr>
<tr>
<td colspan="2"><table border="1" cellpadding="4" cellspacing="4">
<tr>
<td>Texto para el Nuevo MODELO DE IMPRESORA:</td>
</tr>
<tr>
<td><table cellpadding="2" cellspacing="2" bgcolor="#999999">
<tr align="center" valign="middle">
<td><img src="imagenes/negrita.gif" border="2" onClick="textotipoimp.value+='<B></B>'" onMouseOver="this.src='imagenes/negrita_sobre.gif'" onMouseOut="this.src='imagenes/negrita.gif'" /></td>
<td><img src="imagenes/cursiva.gif" width="21" height="20" border="2" onClick="textotipoimp.value+='<I></I>'" onMouseOver="this.src='imagenes/cursiva_sobre.gif'" onMouseOut="this.src='imagenes/cursiva.gif'" /></td>
<td><img src="imagenes/subrayar.gif" width="21" height="20" border="2" onClick="textotipoimp.value+='<U></U>'" onMouseOver="this.src='imagenes/subrayar_sobre.gif'" onMouseOut="this.src='imagenes/subrayar.gif'" /></td>
<td><img src="imagenes/izquierda.gif" width="21" height="20" border="2" onClick="textotipoimp.value+='<P align=left></P>'" onMouseOver="this.src='imagenes/izquierda_sobre.gif'" onMouseOut="this.src='imagenes/izquierda.gif'" /></td>
<td><img src="imagenes/centrar.gif" width="21" height="20" border="2" onClick="textotipoimp.value+='<P align=center></P>'" onMouseOver="this.src='imagenes/centrar_sobre.gif'" onMouseOut="this.src='imagenes/centrar.gif'" /></td>
<td><img src="imagenes/derecha.gif" width="21" height="20" border="2" onClick="textotipoimp.value+='<P align=right></P>'" onMouseOver="this.src='imagenes/derecha_sobre.gif'" onMouseOut="this.src='imagenes/derecha.gif'" /></td>
<td><img src="imagenes/justificar.gif" width="21" height="20" border="2" onClick="textotipoimp.value+='<P align=justify></P>'" onMouseOver="this.src='imagenes/justificar_sobre.gif'" onMouseOut="this.src='imagenes/justificar.gif'" /></td>
<td><select name="color_fuente" size="1" id="color_fuente" onChange="if(color_fuente.selectedIndex=='1')texto tipoimp.value+='<Font Color=#F8CC45></Font>'; if(color_fuente.selectedIndex=='2')textotipoimp.va lue+='<Font Color=#000000></Font>'; if(color_fuente.selectedIndex=='3')textotipoimp.va lue+='<Font Color=#CCCCCC></Font>'; if(color_fuente.selectedIndex=='4')textotipoimp.va lue+='<Font Color=#666666></Font>'; if(color_fuente.selectedIndex=='5')textotipoimp.va lue+='<Font Color=#FF0000></Font>'; if(color_fuente.selectedIndex=='6')textotipoimp.va lue+='<Font Color=#009900></Font>'; if(color_fuente.selectedIndex=='7')textotipoimp.va lue+='<Font Color=#003366></Font>'; if(color_fuente.selectedIndex=='8')textotipoimp.va lue+='<Font Color=#9F4000></Font>'; if(color_fuente.selectedIndex=='9')textotipoimp.va lue+='<Font Color=#FFFF66></Font>';">
<option>Seleccionar Color del Texto</option>
<option>Naranja</option>
<option>Negro</option>
<option>Gris Claro</option>
<option>Gris Oscuro</option>
<option>Rojo</option>
<option>Verde</option>
<option>Azul Oscuro</option>
<option>Marr&oacute;n</option>
<option>Amarillo</option>
</select></td>
<td><img src="imagenes/salto_linea.gif" width="21" height="20" border="2" onClick="textotipoimp.value+='<BR>'" onMouseOver="this.src='imagenes/salto_linea_sobre.gif'" onMouseOut="this.src='imagenes/salto_linea.gif'" /></td>
<td><img src="imagenes/insertar_barra.gif" width="21" height="20" border="2" onClick="textotipoimp.value+='<HR>'" onMouseOver="this.src='imagenes/insertar_barra_sobre.gif'" onMouseOut="this.src='imagenes/insertar_barra.gif'" /></td>
<td><img src="imagenes/insertar_imagen.gif" width="21" height="20" border="2" onClick="textotipoimp.value+='<IMG SRC=>'" onMouseOver="this.src='imagenes/insertar_imagen_sobre.gif'" onMouseOut="this.src='imagenes/insertar_imagen.gif'" /></td>
<td><img src="imagenes/link.gif" width="21" height="20" border="2" onClick="textotipoimp.value+='<A HREF=></A>'" onMouseOver="this.src='imagenes/link_sobre.gif'" onMouseOut="this.src='imagenes/link.gif'" /></td>
<td><img src="imagenes/arroba.gif" width="21" height="20" border="2" onClick="textotipoimp.value+='<A HREF=mailto:*@*.*></A>'" onMouseOver="this.src='imagenes/arroba_sobre.gif'" onMouseOut="this.src='imagenes/arroba.gif'" /></td>
<td><img src="imagenes/borrar.gif" width="21" height="20" border="2" onClick="textotipoimp.value=''" onMouseOver="this.src='imagenes/borrar_sobre.gif'" onMouseOut="this.src='imagenes/borrar.gif'" /></td>
<td><img src="imagenes/ayuda.gif" width="21" height="20" border="2" onClick="window.open('ayuda.php', 'v','scrollbars=1,width=650,height=500,top=5,left= 5');" onMouseOver="this.src='imagenes/ayuda_sobre.gif'" onMouseOut="this.src='imagenes/ayuda.gif'" /></td>
</tr>
</table></td>
</tr>
<tr>
<td><textarea name="textotipoimp" cols="100" rows="3" id="textotipoimp"></textarea></td>
</tr>
</table></td>
</tr>
<tr>
<td colspan="2"><table border="1" cellpadding="4" cellspacing="4">
<tr>
<td>Introducir un Precio:<BR><BR><input name="textopreciocartucho" type="text" id="textopreciocartucho" value="0,00" size="20">
€<BR></td>
</tr>
</table></td>
</tr>
<tr>
<td colspan="2" align="right"><input type="submit" name="submit" id="submit" value="enviar"></td>
</tr>
</form>
<form action="nuevo_tipoimp.php" method="post">
<tr>
<td colspan="2"><input type="submit" name="atras" value="<---"></td>
</tr>
</form>
<form action="tipoimpresoras.php" method="post">
<tr>
<td colspan="2" bgcolor="#CCCCCC"><input name="pag_principal" type="submit" value="<---"> Volver a MODELOS DE IMPRESORAS</td>
</tr>
</form>
</table>
</body>
</html>


Gracias por todo
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 22:44.