Ver Mensaje Individual
  #1 (permalink)  
Antiguo 03/08/2012, 13:33
marce_vampira
 
Fecha de Ingreso: junio-2012
Ubicación: En Chile :D
Mensajes: 44
Antigüedad: 11 años, 10 meses
Puntos: 0
un ayudita para guardar datos en mysql

hola chicos, ya he avanzado en lo que voy (para los que no lo hayan leido o no recuerdan, quiero guardar varios checkbox en una base de datos)... ahora tengo dudas de como guardar todo lo que llega de la primera pagina

esta es la pagina que genera la tabla con loc checkbox

Código PHP:
<?php require_once('Connections/formulario.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;
}
}

mysql_select_db($database_formulario$formulario);
$query_Recordset1 "SELECT * FROM falla_calefon ORDER BY falla ASC";
$Recordset1 mysql_query($query_Recordset1$formulario) or die(mysql_error());
$row_Recordset1 mysql_fetch_assoc($Recordset1);
$totalRows_Recordset1 mysql_num_rows($Recordset1);mysql_select_db($database_formulario$formulario);
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<title>Documento sin título</title>
</head>

<body>

<form action="prueba3.php" method="POST">
<?
if (!$_POST){
?>
    <table border="0">
      <tr>
        <td>&nbsp;</td>
        <td>id</td>
      </tr>
      <?php do { ?>
        <tr>
          <td><input type="checkbox" name="obss[]" id="obss[]" value="<?php echo $row_Recordset1['falla']; ?>"  /></td>
          <td><?php echo $row_Recordset1['falla']; ?></td>
        </tr>
        <?php } while ($row_Recordset1 mysql_fetch_assoc($Recordset1)); ?>
    </table>
<br>
    <input type="submit" value="Enviar datos!" >
    <?php ?>
</form>


</body>
</html>
<?php
mysql_free_result
($Recordset1);
?>
y esta es la pagina que recibe los datos y los guarda:

Código PHP:
<?php require_once('Connections/formulario.php'); ?>
<?php 
    $OBS
=$_POST["obss"];
    
//$n=$_POST["n"];
?>

<?php
    
for ($i=0;$i<count($OBS);$i++)
       {
       
?>    
    
<?php
$observa
=$OBS[$i]." "; }
$sql "UPDATE falla_cocina SET opcion=$observa";
$insertar=mysql_query($sql) or die(mysql_error());
?>
donde esta la falla???