Ver Mensaje Individual
  #1 (permalink)  
Antiguo 09/04/2012, 04:20
ggtc
 
Fecha de Ingreso: abril-2012
Ubicación: minas
Mensajes: 10
Antigüedad: 12 años
Puntos: 0
Problemas para editar en mysql

Hola tengo problemas para editar en mysql como lo dice el titulo, si puedo insertar, buscar pero no editar les cuento lo que me pasa, tengo un codigo en php que al ejecutarlo me envia constantemente a otra pagina que se llama listado.php en la cual me aparecen usuarios y el boton editar pero al apretar en ese boton solo me deja en la misma pagina es como una cadena abierta sin fin, les dejo el codigo a ver que piensan que es:[CODE]

Código PHP:
       include("include/conexion.php");
    include(
"include/funciones.php");

    
$idempresa getParam($_GET["id"], "-1");
    
$action getParam($_GET["action"], "");

    if (
$action == "edit") {
        
$idempresa sqlValue($_POST["id"], "int");
        
$nombre sqlValue($_POST["nombre"], "text");
        
$direccion sqlValue($_POST["direccion"], "text");
        
$telefono sqlValue($_POST["telefono"], "int");
        
        
$sql "UPDATE empresa SET ";
        
$sql.= "nombre=".$nombre.", direccion=".$direccion.", telefono=".$telefono." ";
        
$sql.= "WHERE id=".$idempresa;
        
mysql_query($sql$conexion);
        
header("location: listado.php");
    }

    
$sql "SELECT * FROM empresa WHERE id = ".sqlValue($idempresa"int");
    
$queEmp mysql_query($sql$conexion);
    
$rsEmp mysql_fetch_assoc($queEmp);
    
$total mysql_num_rows($queEmp);
    if (
$total == 0) {
        
header("location: listado.php");
        exit;
    } 
ese es el codigo para editar y ahora pongo el codigo del listado:
Código PHP:
<?php
    
require("include/conexion.php");
    require(
"include/funciones.php");

    
$query "SELECT * FROM empresa ORDER BY nombre ASC";
    
$queEmp mysql_query($query$conexion);
    
?>
    <!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=UTF-8" />
    <title>Listado de Empresas</title>
    <link href="styles.css" rel="stylesheet" type="text/css" />
    </head>
    <body>
    <h3>Listado de  Empresas</h3>
    <table width="600" border="0" cellspacing="0" cellpadding="0">
      <tr>
        <th>Nombre</th>
        <th>Dirección</th>
        <th>&nbsp;</th>
      </tr>
      <?php while ($rsEmp mysql_fetch_assoc($queEmp)) { ?>
      <tr>
        <td><?php echo $rsEmp['nombre']; ?></td>
        <td><?php echo $rsEmp['direccion']; ?></td>
        <td><a href="editar.php?id=<?php echo $rsEmp['id']; ?>">Editar</a></td>
      </tr>
      <?php ?>
    </table>
    <p>&nbsp;</p>
    </body>
    </html>
opinen que tan mal esta todo obvio que tiene muchas cosas para pulir, igual necesito que funcione por ahora.