![Apenado](http://static.forosdelweb.com/fdwtheme/images/smilies/redface.png)
Tengo esta tabla dentro de un formulario, en la cual es posible marcar varias filas, y todas debo guardarlas en una base de datos
Código PHP:
<label for="gus"></label>
<table border="1">
<tr>
<td> </td>
<td>gustos</td>
</tr>
<?php
$i = 0;
do {
?>
<?php echo "<tr><td><input name='obs_".$i."' type='checkbox' id='obs_".$i."' value='".$row_Recordset1[gustos']."'/>
<label for='gus_".$i."'></label></td>
<td>".$row_Recordset1['gustos']."</td>
</tr>";
$i++; ?>
<?php } while ($row_Recordset1 = mysql_fetch_assoc($Recordset1)); ?>
</table>
Código PHP:
<?php require_once('Connections/localhost.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 prueba (prueba) VALUES (%s)",
GetSQLValueString($_POST['obs'], "text"));
mysql_select_db($database_localhost, $localhost);
$Result1 = mysql_query($insertSQL, $localhost) or die(mysql_error());
}
?>