Ver Mensaje Individual
  #5 (permalink)  
Antiguo 05/06/2006, 23:32
fermdp
 
Fecha de Ingreso: diciembre-2001
Ubicación: Mar del Plata
Mensajes: 203
Antigüedad: 22 años, 4 meses
Puntos: 0
Aqui mi codigo

Solo que en vez de radio butons tiene textarea, pues en realidad lo que veo es que NO SE hacer un UPDATE MASIVO !!!??? pues solo me actualiza un solo registro, pordon por postear codigo generado por dreamweaver pero en el apuro era lo que tenia a mano...

Código PHP:
<?php require_once('Connections/fermdp14.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 $HTTP_SERVER_VARS['PHP_SELF'];
if (isset(
$HTTP_SERVER_VARS['QUERY_STRING'])) {
  
$editFormAction .= "?" $HTTP_SERVER_VARS['QUERY_STRING'];
}

if ((isset(
$HTTP_POST_VARS["MM_update"])) && ($HTTP_POST_VARS["MM_update"] == "form1")) {
  
$updateSQL sprintf("UPDATE nota SET Disponible=%s WHERE id=%s",
                       
GetSQLValueString($HTTP_POST_VARS['textfield'], "text"),
                       
GetSQLValueString($HTTP_POST_VARS['hiddenField'], "int"));

  
mysql_select_db($database_fermdp14$fermdp14);
  
$Result1 mysql_query($updateSQL$fermdp14) or die(mysql_error());

  
$updateGoTo "popo.php";
  if (isset(
$HTTP_SERVER_VARS['QUERY_STRING'])) {
    
$updateGoTo .= (strpos($updateGoTo'?')) ? "&" "?";
    
$updateGoTo .= $HTTP_SERVER_VARS['QUERY_STRING'];
  }
  
header(sprintf("Location: %s"$updateGoTo));
}

mysql_select_db($database_fermdp14$fermdp14);
$query_Recordset1 "SELECT * FROM nota";
$Recordset1 mysql_query($query_Recordset1$fermdp14) or die(mysql_error());
$row_Recordset1 mysql_fetch_assoc($Recordset1);
$totalRows_Recordset1 mysql_num_rows($Recordset1);

$maxRows_Recordset1 10;
$pageNum_Recordset1 0;
if (isset(
$HTTP_GET_VARS['pageNum_Recordset1'])) {
  
$pageNum_Recordset1 $HTTP_GET_VARS['pageNum_Recordset1'];
}
$startRow_Recordset1 $pageNum_Recordset1 $maxRows_Recordset1;

mysql_select_db($database_fermdp14$fermdp14);
$query_Recordset1 "SELECT * FROM nota ORDER BY id DESC";
$query_limit_Recordset1 sprintf("%s LIMIT %d, %d"$query_Recordset1$startRow_Recordset1$maxRows_Recordset1);
$Recordset1 mysql_query($query_limit_Recordset1$fermdp14) or die(mysql_error());
$row_Recordset1 mysql_fetch_assoc($Recordset1);

if (isset(
$HTTP_GET_VARS['totalRows_Recordset1'])) {
  
$totalRows_Recordset1 $HTTP_GET_VARS['totalRows_Recordset1'];
} else {
  
$all_Recordset1 mysql_query($query_Recordset1);
  
$totalRows_Recordset1 mysql_num_rows($all_Recordset1);
}
$totalPages_Recordset1 ceil($totalRows_Recordset1/$maxRows_Recordset1)-1?>
<table border="1"><form name="form1" method="POST" action="<?php echo $editFormAction?>">
  <tr> 
    <td>id</td>
    <td>Responsable</td>
    <td>Camara</td>
    <td>Editor</td>
    <td>Disponible</td>
  </tr>
  <?php do { ?>
  <tr> 
    <td><?php echo $row_Recordset1['id']; ?></td>
    <td><?php echo $row_Recordset1['Responsable']; ?></td>
    <td><?php echo $row_Recordset1['Camara']; ?></td>
    <td><?php echo $row_Recordset1['Editor']; ?></td>
    <td><?php echo $row_Recordset1['Disponible']; ?>
      
        <input name="hiddenField" type="hidden" value="<?php echo $row_Recordset1['id']; ?>">
        <input type="text" name="textfield">
        
        <input type="hidden" name="MM_update" value="form1">
      </td>
  </tr>
  <?php } while ($row_Recordset1 mysql_fetch_assoc($Recordset1)); ?>
<input type="submit" name="Submit" value="Submit"></form></table>
<?php mysql_free_result($Recordset1); ?>
Espero que alguien sea tan amable de explicarme el concepto y como seria el hacer un update como este a mas de un registro a la vez !!!
__________________
:) Fernando Dichiera (:
[email protected]