gracias amigo por tomarte tu tiempo pero mira, yo inserto en mi base de datos a la que llamo alumnos los datos de nombre, matricula, horario y aula, estos dos ultimos los recojo de un combobox, este es el codigo:
Código PHP:
<?php require_once('Connections/siscam.php'); ?>
<?php
function GetSQLValueString($theValue, $theType, $theDefinedValue = "", $theNotDefinedValue = "")
{
$theValue = (!get_magic_quotes_gpc()) ? addslashes($theValue) : $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 alumnos (nombre, matricula, horario, aula) VALUES (%s, %s, %s, %s)",
GetSQLValueString($_POST['nombre'], "text"),
GetSQLValueString($_POST['matricula'], "text"),
GetSQLValueString($_POST['horario'], "text"),
GetSQLValueString($_POST['aula'], "text"));
mysql_select_db($database_siscam, $siscam);
$Result1 = mysql_query($insertSQL, $siscam) or die(mysql_error());
$insertGoTo = "datos_insertados.html";
if (isset($_SERVER['QUERY_STRING'])) {
$insertGoTo .= (strpos($insertGoTo, '?')) ? "&" : "?";
$insertGoTo .= $_SERVER['QUERY_STRING'];
}
header(sprintf("Location: %s", $insertGoTo));
}
mysql_select_db($database_siscam, $siscam);
$query_aula = "SELECT grupo_crea FROM grupos";
$aula = mysql_query($query_aula, $siscam) or die(mysql_error());
$row_aula = mysql_fetch_assoc($aula);
$totalRows_aula = mysql_num_rows($aula);
mysql_select_db($database_siscam, $siscam);
$query_horario = "SELECT hora FROM horarios";
$horario = mysql_query($query_horario, $siscam) or die(mysql_error());
$row_horario = mysql_fetch_assoc($horario);
$totalRows_horario = mysql_num_rows($horario);
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<title>Documento sin título</title>
</head>
<body>
<form method="post" name="form1" action="<?php echo $editFormAction; ?>">
<table align="center">
<tr valign="baseline">
<td nowrap align="right">Nombre:</td>
<td><input type="text" name="nombre" value="" size="32"></td>
</tr>
<tr valign="baseline">
<td nowrap align="right">Matricula:</td>
<td><input type="text" name="matricula" value="" size="32"></td>
</tr>
<tr valign="baseline">
<td nowrap align="right">Horario:</td>
<td><select name="horario">
<option value="menuitem1" >seleccionar</option>
<?php
do {
?>
<option value="<?php echo $row_horario['hora']?>"><?php echo $row_horario['hora']?></option>
<?php
} while ($row_horario = mysql_fetch_assoc($horario));
$rows = mysql_num_rows($horario);
if($rows > 0) {
mysql_data_seek($horario, 0);
$row_horario = mysql_fetch_assoc($horario);
}
?>
</select>
</td>
</tr>
<tr valign="baseline">
<td nowrap align="right">Aula:</td>
<td><select name="aula">
<option value="menuitem1" >seleccionar</option>
<?php
do {
?>
<option value="<?php echo $row_aula['grupo_crea']?>"><?php echo $row_aula['grupo_crea']?></option>
<?php
} while ($row_aula = mysql_fetch_assoc($aula));
$rows = mysql_num_rows($aula);
if($rows > 0) {
mysql_data_seek($aula, 0);
$row_aula = mysql_fetch_assoc($aula);
}
?>
</select>
</td>
</tr>
<tr valign="baseline">
<td nowrap align="right"> </td>
<td><input type="submit" value="Insertar registro"></td>
</tr>
</table>
<input type="hidden" name="MM_insert" value="form1">
</form>
<p> </p>
</body>
</html>
<?php
mysql_free_result($aula);
mysql_free_result($horario);
?>
hasta ahi todo bien ahora, en el campo aula, recogido por un combobox, quiero que haya una restriccion, de solo recoger 40 datos para cada aula, entonces lo que quiero hacer es recogerlo en consultas por salon, para tener el control por salon, lo que no se es como limitar para que el sistema solo registre 40 datos por aula, y la verdad me revolvistes un poco, aunque parte del codigo lo probare orita y luego te cuento gracias de nuevo