Ver Mensaje Individual
  #12 (permalink)  
Antiguo 01/12/2005, 09:51
maac78
 
Fecha de Ingreso: noviembre-2005
Mensajes: 45
Antigüedad: 18 años, 5 meses
Puntos: 1
Funciona Mil Gracias A Todos

Hola a todo,

despues de mucho, y gracias a Kayetano y a has el sistema funciona.

Os pogno el codigo que tengo

Codigo 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']);
}

foreach($_POST['seleccion'] as $k => $v) {
if ((isset($_POST["MM_insert"])) && ($_POST["MM_insert"] == "form1")) {
$insertSQL = sprintf("INSERT INTO prueba (nombre, apellidos) VALUES (%s, %s)",
GetSQLValueString($_POST['nombre'][$k], "text"),
GetSQLValueString($_POST['apellidos'][$k], "text"));

mysql_select_db($database_con_pb, $con_pb);
$Result1 = mysql_query($insertSQL, $con_pb) or die(mysql_error());

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

El formulario

form action="<?php echo $editFormAction; ?>" name="form1" method="POST">
<p>1
<input name="seleccion[1]" type="checkbox" value="1" id="seleccion[1]" />
nombre
<label>
<input name="nombre[1]" type="text" id="nombre[1]"/>
</label>
apellidos
<input name="apellidos[1]" type="text" id="apellidos[1]"/>
</p>
<p>2
<input name="seleccion[2]" type="checkbox" value="2" id="seleccion[2]"/>
nombre
<input name="nombre[2]" type="text" id="nombre[2]" />
apellidos
<input name="apellidos[2]" type="text" id="apellidos[2]"/>
</p>
<p>3
<input name="seleccion[3]" type="checkbox" value="3" id="seleccion[3]" />
nombre
<input name="nombre[3]" type="text" id="nombre[3]" />
apellidos
<input name="apellidos[3]" type="text" id="apellidos[3]" />
</p>
<p>
<input type="submit" name="Submit" value="Enviar">
<label></label>

Mil gracias, y como lo prometido es deuda si he de pagar algo me lo decis, pero no os paseis.