Foros del Web » Programando para Internet » PHP »

Como Invocar Parametro URL Para Editar Un Registro de Base de Datos

Estas en el tema de Como Invocar Parametro URL Para Editar Un Registro de Base de Datos en el foro de PHP en Foros del Web. Buenas Tardes, Tengo una pagina de resultados de una consulta a mi base de datos que configure para que saliera en una tabla, adicione un ...
  #1 (permalink)  
Antiguo 29/07/2009, 15:04
 
Fecha de Ingreso: julio-2009
Ubicación: Bogota
Mensajes: 37
Antigüedad: 14 años, 8 meses
Puntos: 0
Exclamación Como Invocar Parametro URL Para Editar Un Registro de Base de Datos

Buenas Tardes,

Tengo una pagina de resultados de una consulta a mi base de datos que configure para que saliera en una tabla, adicione un link para editar el registro, estoy enviando un parametro url para tomar el campo principal en mi formulario o pagina de edicion pero no me funciona.

Agradezco cualquier ayuda y envio el codigo relacionado:

Resultado de Consulta en MySQL y Parametro URL:

Código PHP:
$consulta mysql_query("SELECT * FROM personal WHERE Cedula LIKE '%".$Cedula."' AND FECHA LIKE '%".$FECHA."' AND Mail LIKE '%".$Mail."%' AND Nombre LIKE '%".$Nombre."' AND Telefono LIKE '%".$Telefono."' ",$con );
$encontrados mysql_num_rows($consulta); 
if(
$encontrados 0){ 
    while(
$row mysql_fetch_array($consulta)){  
        echo 
        
//"<p>".$row['Cedula']." - ".$row['FECHA']." - ".$row['Mail']." - ".$row['Nombre']." - ".$row['Telefono'].  "</p> "  ;  
        
'
        <table align="center" border="1">
            <tr>
                <td align="center" width="20%">'
.$row['Cedula'].'</td>
                <td align="center" width="20%">'
.$row['FECHA'].'</td>
                <td align="center" width="20%">'
.$row['Mail'].'</td>
                <td align="center" width="20%">'
.$row['Nombre'].'</td>
                <td align="center" width="20%">'
.$row['Telefono'].'</td>
                <td align="center" width="20%"><a href="FormEdita.php?id_registro='
.$row['Cedula'].'">Editar</a></td> 

            </tr>    
        </table>
        
        '
;    
    } 
}else{ 
    echo 
'No se han encontrado datos'

Pagina PHP para Edicion:


Código PHP:
<?php require_once('Connections/FormPrueba.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_update"])) && ($_POST["MM_update"] == "form1")) {
  
$updateSQL sprintf("UPDATE personal SET Telefono=%s, Nombre=%s, Mail=%s, FECHA=%s WHERE Cedula=%s",
                       
GetSQLValueString($_POST['Telefono'], "text"),
                       
GetSQLValueString($_POST['Nombre'], "text"),
                       
GetSQLValueString($_POST['Mail'], "text"),
                       
GetSQLValueString($_POST['FECHA'], "date"),
                       
GetSQLValueString($_POST['Cedula'], "text"));

  
mysql_select_db($database_FormPrueba$FormPrueba);
  
$Result1 mysql_query($updateSQL$FormPrueba) or die(mysql_error());

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

$colname_Editar "-1";
if (isset(
$_GET['<? echo $Cedula ?>'])) {
  
$colname_Editar $_GET['<? echo $Cedula ?>'];
}
mysql_select_db($database_FormPrueba$FormPrueba);
$query_Editar sprintf("SELECT * FROM personal WHERE Cedula = %s"GetSQLValueString($colname_Editar"text"));
$Editar mysql_query($query_Editar$FormPrueba) or die(mysql_error());
$row_Editar mysql_fetch_assoc($Editar);
$totalRows_Editar mysql_num_rows($Editar);
?>
Agradezco su atencion y ayuda.
  #2 (permalink)  
Antiguo 29/07/2009, 16:32
 
Fecha de Ingreso: mayo-2009
Mensajes: 210
Antigüedad: 14 años, 10 meses
Puntos: 0
Respuesta: Como Invocar Parametro URL Para Editar Un Registro de Base de Datos

pero que error te tira?? Error de sintaxis?? O ningun error pero no edita?
Así nos das una pista
Atención: Estás leyendo un tema que no tiene actividad desde hace más de 6 MESES, te recomendamos abrir un Nuevo tema en lugar de responder al actual.
Respuesta




La zona horaria es GMT -6. Ahora son las 20:06.