¿Cómo puedo hacer que este código someterse al cargar la página ..

  • Mozzi
  • Student
  • Student
  • No Avatar
  • Registrado: Ago 19, 2004
  • Mensajes: 70
  • Status: Offline

Nota Enero 22nd, 2010, 11:22 pm

Hola .. He actualización de esta página .. pero tengo un formulario en ella .. Quiero formar a autosubmit en la carga

o mejor aún la recodificación de modo de actualizar sin tener que presentar...

¿Hay alguna forma de volver a codificar esto???

He tratado de eliminar el if (isset ($ _POST [ "button"])) por lo que automáticamente las actualizaciones .. pero no tengo suerte, como parece que esto debe ser presionado para hacer la función .. soy un poco novato para codificar la codificación manual .. así que si alguien podría ayudar, entonces sería una gran

Código: [ Select ]
<?php require_once('../Connections/customer_zone.php'); ?>
<?php
if (!function_exists("GetSQLValueString")) {
function GetSQLValueString($theValue, $theType, $theDefinedValue = "", $theNotDefinedValue = "")
{
 $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']);
}

mysql_select_db($database_customer_zone, $customer_zone);
$query_Recordset1 = "SELECT * FROM claims";
$Recordset1 = mysql_query($query_Recordset1, $customer_zone) or die(mysql_error());
$row_Recordset1 = mysql_fetch_assoc($Recordset1);
$totalRows_Recordset1 = mysql_num_rows($Recordset1);

// *** FX Update Multiple Records in form1
if (isset($startRow_Recordset1)) $upd_Recordset1 = $startRow_Recordset1; else $upd_Recordset1 = 0; // counter
if (isset($_POST['button'])) {
 $FX_sqlerror = "";
 $FX_updredir = "view_claim.php";
 mysql_select_db($database_customer_zone, $customer_zone);
 for ($N=$upd_Recordset1+1; $N<=$totalRows_Recordset1; $N++) {
  $updt_SQL = sprintf("UPDATE claims SET policy_gi_ref=%s, `read`=%s WHERE policy_gi_ref=%s",
            isset($_POST["policy_gi_ref$N"]) ? ($_POST["policy_gi_ref$N"] != "" ? ("'".addslashes(stripslashes($_POST["policy_gi_ref$N"]))."'") : "NULL") : "''",
            isset($_POST["read$N"]) ? ($_POST["read$N"] != "" ? ("'".addslashes(stripslashes($_POST["read$N"]))."'") : "NULL") : "''",
            isset($_POST["fx_updmatch$N"]) ? ($_POST["fx_updmatch$N"] != "" ? ("'".addslashes(stripslashes($_POST["fx_updmatch$N"]))."'") : "NULL") : "''");
  $updt_Result = mysql_query($updt_SQL, $customer_zone) or $FX_sqlerror .= "Row ".$N.": " . mysql_error() . "<br><br>";
 }
 if ($FX_updredir == "") $FX_updredir = basename($_SERVER['SCRIPT_NAME']);
 if (isset($_SERVER['QUERY_STRING'])) {
  $FX_updredir .= (strpos($FX_updredir, '?')) ? "&" : "?";
  $FX_updredir .= $_SERVER['QUERY_STRING'];
 }
 if ($FX_sqlerror != "") {
  echo '<font color="red">'.$FX_sqlerror.'</font>';
 } else header("Location: " . $FX_updredir);
}
?>

<form id="form1" name="form1" method="POST" action="<?php echo $editFormAction; ?>">
 <?php do { ?>

     <?php $upd_Recordset1++; ?>
     <input type="hidden" name="fx_updmatch<?php echo $upd_Recordset1; ?>" value="<?php echo $row_Recordset1['policy_gi_ref']; ?>" />
     <input name="policy_gi_ref<?php echo $upd_Recordset1; ?>" type="hidden" id="policy_gi_ref" value="<?php echo $row_Recordset1['policy_gi_ref']; ?>" />
    <input name="read<?php echo $upd_Recordset1; ?>" type="hidden" id="read" value="no" />

  <?php } while ($row_Recordset1 = mysql_fetch_assoc($Recordset1)); ?>


  <input type="submit" name="button" id="button" value="Submit" />

</form>

<?php
mysql_free_result($Recordset1);
?>
  1. <?php require_once('../Connections/customer_zone.php'); ?>
  2. <?php
  3. if (!function_exists("GetSQLValueString")) {
  4. function GetSQLValueString($theValue, $theType, $theDefinedValue = "", $theNotDefinedValue = "")
  5. {
  6.  $theValue = get_magic_quotes_gpc() ? stripslashes($theValue) : $theValue;
  7.  $theValue = function_exists("mysql_real_escape_string") ? mysql_real_escape_string($theValue) : mysql_escape_string($theValue);
  8.  switch ($theType) {
  9.   case "text":
  10.    $theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL";
  11.    break;
  12.   case "long":
  13.   case "int":
  14.    $theValue = ($theValue != "") ? intval($theValue) : "NULL";
  15.    break;
  16.   case "double":
  17.    $theValue = ($theValue != "") ? "'" . doubleval($theValue) . "'" : "NULL";
  18.    break;
  19.   case "date":
  20.    $theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL";
  21.    break;
  22.   case "defined":
  23.    $theValue = ($theValue != "") ? $theDefinedValue : $theNotDefinedValue;
  24.    break;
  25.  }
  26.  return $theValue;
  27. }
  28. }
  29. $editFormAction = $_SERVER['PHP_SELF'];
  30. if (isset($_SERVER['QUERY_STRING'])) {
  31.  $editFormAction .= "?" . htmlentities($_SERVER['QUERY_STRING']);
  32. }
  33. mysql_select_db($database_customer_zone, $customer_zone);
  34. $query_Recordset1 = "SELECT * FROM claims";
  35. $Recordset1 = mysql_query($query_Recordset1, $customer_zone) or die(mysql_error());
  36. $row_Recordset1 = mysql_fetch_assoc($Recordset1);
  37. $totalRows_Recordset1 = mysql_num_rows($Recordset1);
  38. // *** FX Update Multiple Records in form1
  39. if (isset($startRow_Recordset1)) $upd_Recordset1 = $startRow_Recordset1; else $upd_Recordset1 = 0; // counter
  40. if (isset($_POST['button'])) {
  41.  $FX_sqlerror = "";
  42.  $FX_updredir = "view_claim.php";
  43.  mysql_select_db($database_customer_zone, $customer_zone);
  44.  for ($N=$upd_Recordset1+1; $N<=$totalRows_Recordset1; $N++) {
  45.   $updt_SQL = sprintf("UPDATE claims SET policy_gi_ref=%s, `read`=%s WHERE policy_gi_ref=%s",
  46.             isset($_POST["policy_gi_ref$N"]) ? ($_POST["policy_gi_ref$N"] != "" ? ("'".addslashes(stripslashes($_POST["policy_gi_ref$N"]))."'") : "NULL") : "''",
  47.             isset($_POST["read$N"]) ? ($_POST["read$N"] != "" ? ("'".addslashes(stripslashes($_POST["read$N"]))."'") : "NULL") : "''",
  48.             isset($_POST["fx_updmatch$N"]) ? ($_POST["fx_updmatch$N"] != "" ? ("'".addslashes(stripslashes($_POST["fx_updmatch$N"]))."'") : "NULL") : "''");
  49.   $updt_Result = mysql_query($updt_SQL, $customer_zone) or $FX_sqlerror .= "Row ".$N.": " . mysql_error() . "<br><br>";
  50.  }
  51.  if ($FX_updredir == "") $FX_updredir = basename($_SERVER['SCRIPT_NAME']);
  52.  if (isset($_SERVER['QUERY_STRING'])) {
  53.   $FX_updredir .= (strpos($FX_updredir, '?')) ? "&" : "?";
  54.   $FX_updredir .= $_SERVER['QUERY_STRING'];
  55.  }
  56.  if ($FX_sqlerror != "") {
  57.   echo '<font color="red">'.$FX_sqlerror.'</font>';
  58.  } else header("Location: " . $FX_updredir);
  59. }
  60. ?>
  61. <form id="form1" name="form1" method="POST" action="<?php echo $editFormAction; ?>">
  62.  <?php do { ?>
  63.      <?php $upd_Recordset1++; ?>
  64.      <input type="hidden" name="fx_updmatch<?php echo $upd_Recordset1; ?>" value="<?php echo $row_Recordset1['policy_gi_ref']; ?>" />
  65.      <input name="policy_gi_ref<?php echo $upd_Recordset1; ?>" type="hidden" id="policy_gi_ref" value="<?php echo $row_Recordset1['policy_gi_ref']; ?>" />
  66.     <input name="read<?php echo $upd_Recordset1; ?>" type="hidden" id="read" value="no" />
  67.   <?php } while ($row_Recordset1 = mysql_fetch_assoc($Recordset1)); ?>
  68.   <input type="submit" name="button" id="button" value="Submit" />
  69. </form>
  70. <?php
  71. mysql_free_result($Recordset1);
  72. ?>
  • Anonymous
  • Bot
  • No Avatar
  • Registrado: 25 Feb 2008
  • Mensajes: ?
  • Loc: Ozzuland
  • Status: Online

Nota Enero 22nd, 2010, 11:22 pm

  • nexuslite
  • Newbie
  • Newbie
  • No Avatar
  • Registrado: Feb 11, 2010
  • Mensajes: 10
  • Loc: Keizer, OR
  • Status: Offline

Nota Febrero 11th, 2010, 6:03 am

Generalmente uso

Código: [ Select ]
if (isset($_POST) && count($_POST)) {
}
  1. if (isset($_POST) && count($_POST)) {
  2. }


en lugar de

Código: [ Select ]
if (isset($_POST['button'])) {
}
  1. if (isset($_POST['button'])) {
  2. }



de esta manera sólo es comprobar si la variable se ha puesto de contenido. a continuación, presentar un formulario de JavaScript tendrá que formar parte de ella para que sea auto enviar el formulario.

Publicar Información

  • Total de mensajes en este tema: 2 mensajes
  • Usuarios navegando por este Foro: Zealous y 209 invitados
  • No puede abrir nuevos temas en este Foro
  • No puede responder a temas en este Foro
  • No puede editar sus mensajes en este Foro
  • No puede borrar sus mensajes en este Foro
  • No puede enviar adjuntos en este Foro
 
 

© 2011 Unmelted, LLC. Ozzu® es una marca registrada de Unmelted, LLC