Foros del Web » Programando para Internet » PHP »

Formulario con menu despleglable y BD

Estas en el tema de Formulario con menu despleglable y BD en el foro de PHP en Foros del Web. Hola que tal, pues soy nuevo en esto, aunque he visto varios temas por aquí. Resulta que tengo un formulario y su respectivo script. (que ...
  #1 (permalink)  
Antiguo 25/03/2013, 16:00
 
Fecha de Ingreso: marzo-2013
Mensajes: 72
Antigüedad: 11 años
Puntos: 0
Busqueda Formulario con menu despleglable y BD

Hola que tal, pues soy nuevo en esto, aunque he visto varios temas por aquí.
Resulta que tengo un formulario y su respectivo script. (que muestro mas adelante)
Bueno ya me quebré la cabeza por dos días, y decidí pedir ayuda.
Ya funciona al desplegar el menú/lista, selecciona cualquiera de las dos opciones. al seleccionar 2 MAESTROS Y 1 AUXILIAR y se despliega tres campos de texto 2 para maestros y uno para auxiliar y también al seleccionar 2 MAESTROS Y 2 AUXILIAR, pero solo detecta la segunda opción y escribe en bd pero al seleccionar la primera opción y llenar los campos no escribe en BD ME PUEDEN AYUDAR

<tr valign="baseline">
<td align="right" nowrap="nowrap">&iquest;Qui&eacute;nimparti&oacute ; el Curso?</td>
<td valign="baseline">
<p>
<label for="selmaestros"></label>
<select name="selmaestros" id="selmaestros" onChange="selmaestro(this)">
<option value=""></option>
<option value="2MAESTROSY1AUXILIAR">2 MAESTROS Y 1 AUXILIAR</option>
<option value="2MAESTROSY2AUXILIAR">2 MAESTROS Y 2 AUXILIAR</option>
</select>
</p>
<div class="maestro1" style="display: none;">
<table width="105%" border="0">
<tr valign="baseline">
<td nowrap="nowrap" align="right"><label>Maestro 1:</label> </td>
<td><input name="quien_impartio_maestro1" type="text" value="" size="32"/></td>
</tr>
<tr valign="baseline">
<td nowrap="nowrap" align="right"><label>Maestro 2:</label> </td>
<td><input name="quien_impartio_maestro2" type="text" value="" size="32"/></td>
</tr>
<tr valign="baseline">
<td nowrap="nowrap" align="right"><label>Auxiliar 1:</label> </td>
<td><input name="quien_impartio_auxiliar1" type="text" value="" size="32"/></td>
</tr>
</table>
</div>
<div class="maestro1" style="display: none;">
<table width="105%" border="0">
<tr valign="baseline">
<td nowrap="nowrap" align="right"><label>Maestro 1:</label> </td>
<td><input name="quien_impartio_maestro1" type="text" value="" size="32"/></td>
</tr>
<tr valign="baseline">
<td nowrap="nowrap" align="right"><label>Maestro 2:</label> </td>
<td><input name="quien_impartio_maestro2" type="text" value="" size="32"/></td>
</tr>
<tr valign="baseline">
<td nowrap="nowrap" align="right"><label>Auxiliar 1:</label> </td>
<td><input name="quien_impartio_auxiliar1" type="text" value="" size="32"/></td>
</tr>
<tr valign="baseline">
<td nowrap="nowrap" align="right"><label>Auxiliar 2:</label> </td>
<td><input name="quien_impartio_auxiliar2" type="text" value="" size="32"/></td>
</tr>
</table>
</div>
</td>
</tr>

OBVIO con su respectivo script que es:
<script>
function selmaestro(sel) {
if (sel.value=="2MAESTROSY1AUXILIAR"){
$(".maestro1").show();
$(".maestro2").hide();
}
else{
$(".maestro2").show();
$(".maestro1").hide();
}
}
</script>
  #2 (permalink)  
Antiguo 25/03/2013, 16:02
 
Fecha de Ingreso: abril-2008
Ubicación: El Salvador
Mensajes: 736
Antigüedad: 16 años
Puntos: 47
Respuesta: Formulario con menu despleglable y BD

Necesitariamos ver el codigo con el que guardas en la base
  #3 (permalink)  
Antiguo 25/03/2013, 16:23
 
Fecha de Ingreso: marzo-2013
Mensajes: 72
Antigüedad: 11 años
Puntos: 0
Respuesta: Formulario con menu despleglable y BD

alex1084..... grax por responder pero... a que te refieres con codigo con que guardo en bd si, si guarda. solo seleccionando la segunda opcion, pero aqui te dejo mi codigo

<?php require_once('../Connections/conexion.php'); ?>

<?php
if (!function_exists("GetSQLValueString")) {
function GetSQLValueString($theValue, $theType, $theDefinedValue = "", $theNotDefinedValue = "")
{
if (PHP_VERSION < 6) {
$theValue = get_magic_quotes_gpc() ? stripslashes($theValue) : $theValue;
}

$theValue = function_exists("mysql_real_escape_string") ? mysql_real_escape_string($theValue) : mysql_escape_string($theValue);

switch ($theType) {
case "text":
$theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL";
break;
case "long":
case "int":
$theValue = ($theValue != "") ? intval($theValue) : "NULL";
break;
case "double":
$theValue = ($theValue != "") ? doubleval($theValue) : "NULL";
break;
case "date":
$theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL";
break;
case "defined":
$theValue = ($theValue != "") ? $theDefinedValue : $theNotDefinedValue;
break;
}
return $theValue;
}
}

$editFormAction = $_SERVER['PHP_SELF'];
if (isset($_SERVER['QUERY_STRING'])) {
$editFormAction .= "?" . htmlentities($_SERVER['QUERY_STRING']);
}


if ((isset($_POST["MM_insert"])) && ($_POST["MM_insert"] == "form1")) {
$insertSQL = sprintf("INSERT INTO puertos (fecha_actualizacion, nombre_de_puerto, num_inscritos, num_graduados, fecha_certificacion, quien_impartio_maestro1, quien_impartio_maestro2, quien_impartio_auxiliar1, quien_impartio_auxiliar2, nom_iglesia, comentarios) VALUES (%s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s)",
GetSQLValueString($_POST['fecha_actualizacion'], "date"),
GetSQLValueString($_POST['nombre_de_puerto'], "text"),
GetSQLValueString($_POST['num_inscritos'], "int"),
GetSQLValueString($_POST['num_graduados'], "int"),
GetSQLValueString($_POST['fecha_certificacion'], "date"),
GetSQLValueString($_POST['quien_impartio_maestro1'], "text"),
GetSQLValueString($_POST['quien_impartio_maestro2'], "text"),
GetSQLValueString($_POST['quien_impartio_auxiliar1'], "text"),
GetSQLValueString($_POST['quien_impartio_auxiliar2'], "text"),
GetSQLValueString($_POST['nom'], "text"),
GetSQLValueString($_POST['comentarios'], "text"));

mysql_select_db($database_conexionelrio, $conexionelrio);
$Result1 = mysql_query($insertSQL, $conexionelrio) or die(mysql_error());

$insertGoTo = "eEntrenar_2puertos_ver.php";
if (isset($_SERVER['QUERY_STRING'])) {
$insertGoTo .= (strpos($insertGoTo, '?')) ? "&" : "?";
$insertGoTo .= $_SERVER['QUERY_STRING'];
}
header(sprintf("Location: %s", $insertGoTo));
}

Etiquetas: bd, formulario, select
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 14:56.