Foros del Web » Programando para Internet » PHP »

Presentacion de datos

Estas en el tema de Presentacion de datos en el foro de PHP en Foros del Web. Tengo un codigo que me obtiene informacion de una BD de MySQL pero no muestra la informacion despues de la busqueda, no veo donde esta ...
  #1 (permalink)  
Antiguo 26/01/2013, 22:54
Avatar de Simon_Echecopar  
Fecha de Ingreso: marzo-2012
Mensajes: 96
Antigüedad: 12 años, 1 mes
Puntos: 0
Presentacion de datos

Tengo un codigo que me obtiene informacion de una BD de MySQL pero no muestra la informacion despues de la busqueda, no veo donde esta el problema y me falta hacer que responde al UPDATE que todavia no hago:
Código PHP:
<?php
 $count
=0;
include 
"conexion.php";
$idvendedor             $_GET["idvendedor"];

$sql "SELECT e.idvendedor,e.llavesocio, e.nombrevend, e.telvend, e.celvend, e.emailvend, e.FecAlta, e.fecbaja FROM cat_vendedores AS e";

if(!empty(
$idvendedor))
{
 
$sql .= " WHERE e.idvendedor = ".$idvendedor;
 
}
if(isset(
$_REQUEST["Busqueda"]))
{

 
$vUsuario      $_POST["vUsuario"];
 
$vNombre        $_POST["vNombre"];
 
$vTelefono        $_POST["vTelefono"];
 
$vCelular        $_POST["vCelular"];
 
$vEmail        $_POST["vEmail"];
 
$vNomArea        $_POST["vNomArea"];
 
$vBaja            $_POST["vBaja"];
 
$vAlta            $_POST["vAlta"];
 
$count=0;
 
$sql .= " WHERE ";
 if(!empty(
$vUsuario))
 {
  
$count++;
  if(
$count>1)
   
$sql .= "AND ";
  
$sql .= " cvesocio LIKE '".$vUsuario."'";
  
//echo $sql."<br>";
 
}
 
 if(!empty(
$vNombre))
 {
  
$count++;
  if(
$count>1)
   
$sql .= " AND ";
  
$sql .= " nombrevend LIKE '".$vNombre."'";
  
//echo $sql."<br>";
 
}
 
 if(!empty(
$vTelefono))
 {
  
$count++;
  if(
$count>1)
   
$sql .= " AND ";
  
$sql .= "telvend = ".$vTelefono;
  
//echo $sql."<br>";
 
}
 
 if(!empty(
$vCelular))
 {
  
$count++;
  if(
$count>1)
   
$sql .= " AND ";
  
$sql .= "celvend = ".$vCelular;
  
//echo $sql."<br>";
 
}
 
 if(!empty(
$vEmail))
 {
  
$count++;
  if(
$count>1)
   
$sql .= " AND ";
  
$sql .= "emailvend = '".$vEmail."'";
  
//echo $sql."<br>";
 
}

 if(!empty(
$vNomArea))
 {
  
$count++;
  
$sAre "SELECT id_area FROM areas WHERE desc_area LIKE '".$vNomArea."'";
  
$reAre mysql_query($sAre);
  
$roAre mysql_fetch_row($reAre);
  
//var_dump($roAre[0]);
  //echo $sql."<br>";
  
if($count>1)
   
$sql .= " AND ";
  
$sql .= "idarea = ".$roAre[0];
 }

 if(!empty(
$vBaja))
 {
  
$count++;
  if(
$count>1)
   
$sql .= " AND ";
  
$sql .= "fecbaja = '".$vBaja."'";
  
//echo $sql."<br>";
 
}
 if(!empty(
$vAlta))
 {
  
$count++;
  if(
$count>1)
   
$sql .= " AND ";
  
$sql .= "FecAlta = '".$vAlta."'";
  
//echo $sql."<br>";
 
}
 echo 
$sql;
 
//echo  $count;
}
$resultado mysql_query($sql,$link);
?>
<?PHP 
include ("seguridad.php");?>
<?PHP 
require ("clase_mysql.inc.php"); ?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" lang="en">
<head>
  <meta http-equiv="content-type" content="text/html; charset=UTF8" />
  <!--<meta http-equiv="content-type" content="text/html; charset=ISO-8859-1" />-->
  <link rel="stylesheet" type="text/css" media="screen,projection,print" href="./css/layout1a_setup.css" />
  <link rel="stylesheet" type="text/css" media="screen,projection,print" href="./css/layout1a_text.css" />
  <title>S&iacute;stema de Facturaci&oacute;n Asgui </title>
</head>
<!-- Global IE fix to avoid layout crash when single word size wider than column width -->
<!--[if IE]><style type="text/css"> body {word-wrap: break-word;}</style><![endif]-->
<body>
 <center>
  <!-- Main Page Container -->
  <div class="page-container">
    <!-- For alternative headers START PASTE here -->
    <!-- A. HEADER -->      
    <div class="header">
      <!-- A.2 HEADER MIDDLE -->
      <div class="header-middle">    
        <!-- Site message -->
      </div>
      <!-- A.3 HEADER BOTTOM -->
      <div class="header-bottom">
        <!-- Navigation Level 2 (Drop-down menus) -->
        <div class="nav2">
            <p align="right">Usuario: <b><? echo $_SESSION["nombresocio"];?></b>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</p>
            <? include 'barramenu.php'?>  
        </div>
      </div>
    </div>
    <!-- For alternative headers END PASTE here -->
    <!-- B. MAIN -->
    <div class="main">
      <!-- B.1 MAIN CONTENT -->
      <div class="main-content">
        <hr class="clear-contentunit" />
        <h1 class="block"><center>Usuarios del Sistema</center></h1> 
        <!-- Comienza código -->
     <form method="POST" action="abcEmpleado.php"> 
      <input type="hidden" name="idarea1" value="<?php print $idarea1?>">
      <input type="hidden" name="idvendedor" value="<?php print $idvendedor ?>">
      <table border=0>
       <tr>
        <th class="top" scope="col" width="90">Usuario</th>
        <th><input type="text" name="vUsuario" value = "<?php print $vUsuario ?>" size="100"></td>
       </tr>
       <tr>
        <th class="top" scope="col" width="90">Nombre</th>
        <th><input type="text" name="vNombre" value = "<?php print $vNombre ?>" size="100"></td>
       </tr>
       <tr>
        <th class="top" scope="col" width="90">Telefono</th>
        <th><input type="text" name="vTelefono" value = "<?php print $vTelefono ?>" size="100"></td> 
       </tr>
       <tr>
        <th class="top" scope="col" width="90">Celular</th>
        <th><input type="text" name="vCelular" value = "<?php print $vCelular ?>" size="100"></td>
       </tr>
       <tr>
        <th class="top" scope="col" width="90">e-mail</th>
        <th><input type="text" name="vEmail" value = "<?php print $vEmail ?>" size="100"></td>
       </tr>
       <tr>
        <th class="top" scope="col" width="90">Nombre de Area</th>
        <th><input type="text" name="vNomArea" value = "<?php print $vNomArea ?>" size="100"></td>
       </tr>
       <tr>
        <th class="top" scope="col" width="90">Fecha Alta</th>
        <th><input type="text" name="vAlta" value = "<?php print $vAlta ?>" size="100"></td>
       </tr>
       <tr>
        <th class="top" scope="col" width="90">Fecha Baja</th>
        <th><input type="text" name="vBaja" value = "<?php print $vBaja ?>" size="100"></td>
       </tr>
       <tr>
        <th></td>
        <td align=right><input type="submit" id="Busqueda" name="Busqueda" value="<?php if(!empty($idvendedor)) print "Modificar"; else print "Buscar";?>"></td>
       </tr>
      </table>
     </form>
     <form method="GET" action="abcEmpleado.php">
     <table>
      <tr>
        <th class="top" scope="col" width="25">ID:</th>
        <th class="hpedidotit" scope="col" width="60">Usuario</th>
        <th class="hpedidotit" scope="col" width="60">Nombre</th>
        <th class="hpedidotit" scope="col" width="60">Telefono</th>
        <th class="hpedidotit" scope="col" width="70">Celular</th>
        <th class="hpedidotit" scope="col" width="130">Email</th>
        <th class="hpedidotit" scope="col" width="80">Area</th>
        <th class="hpedidotit" scope="col" width="90">Acciones</th>
        <th class="hpedidotit" scope="col" width="60">Fecha de Alta</th>
        <th class="hpedidotit" scope="col" width="60">Fecha de Baja</th>
      </tr>
      <?PHP
        
//var_dump($row=mysql_fetch_row($resultado));
      
        
while ($row=mysql_fetch_row($resultado)) // recorre los clientes uno por uno hasta el fin de la tabla
        
{
          
$SQLnomArea 'SELECT desc_area FROM areas WHERE id_area = (SELECT idarea FROM cat_vendedores WHERE idvendedor = '.$row[0].')';
          
$resultado2 mysql_query($SQLnomArea,$link);
          
$fila2=mysql_fetch_row($resultado2); 
          print 
'<tr><td class="'.$clase_celda.'"><a href="abcEmpleado.php?idvendedor='.$row[0].'">'.$row[0].'</a></td>';
          print 
'<td class="'.$clase_celda.'" >'.$row[1].'</td>';
          print 
'<td class="'.$clase_celda.'" >'.$row[2].'</td>';
          print 
'<td class="'.$clase_celda.'" >'.$row[3].'</td>';
          print 
'<td class="'.$clase_celda.'" >'.$row[4].'</td>';
          print 
'<td class="'.$clase_celda.'" >'.$row[5].'</td>';
          print 
'<td class="'.$clase_celda.'" >'.$fila2[0].'</td>';
          print 
'<td class="'.$clase_celda.'" >'.''.'</td>';
          print 
'<td class="'.$clase_celda.'" >'.$row[6].'</td>';
          print 
'<td class="'.$clase_celda.'" >'.$row[7].'</td>';
         }
//*/
?>

     </table>
     </form>
   </div>
  </div>
  </center>
 </body>
</html>
<?php 
@mysql_free_result($resultado);
@
mysql_free_result($resultado2);
@
mysql_free_result($reAre);
?>
  #2 (permalink)  
Antiguo 27/01/2013, 06:40
Avatar de Triby
Mod on free time
 
Fecha de Ingreso: agosto-2008
Ubicación: $MX->Gto['León'];
Mensajes: 10.106
Antigüedad: 15 años, 8 meses
Puntos: 2237
Respuesta: Presentacion de datos

Código PHP:
Ver original
  1. // Esto está mal
  2. $idvendedor             = $_GET["idvendedor"];
  3. if(!empty($idvendedor))
  4. {
  5.  $sql .= " WHERE e.idvendedor = ".$idvendedor;
  6. }
  7.  
  8. // Debería ser algo como:
  9. $idvendedor = false;
  10. if(isset($_GET["idvendedor"])) {
  11.     $idvendedor = $_GET["idvendedor"];
  12.     // Aquí necesitas validar que el valor sea lo que esperas
  13.     // Ya sea numérico, alfanumérico, etc.
  14.     // Y que el vendedor realmente existe
  15. }

Qué obtienes en echo $sql; ?, prueba la consulta en PhpMyAdmin y dinos si funciona o no.
__________________
- León, Guanajuato
- GV-Foto
  #3 (permalink)  
Antiguo 27/01/2013, 14:05
Avatar de Simon_Echecopar  
Fecha de Ingreso: marzo-2012
Mensajes: 96
Antigüedad: 12 años, 1 mes
Puntos: 0
Respuesta: Presentacion de datos

el echo $sql es para poder ver el query ver si concatena como se debe. Probare lo que me dices. Aún me falta validar la seleccion del select y del update que no he hecho.
  #4 (permalink)  
Antiguo 29/01/2013, 15:35
Avatar de Simon_Echecopar  
Fecha de Ingreso: marzo-2012
Mensajes: 96
Antigüedad: 12 años, 1 mes
Puntos: 0
Respuesta: Presentacion de datos

Triby, ya probe lo tuyo, da lo mismo.

Cita:
Iniciado por Triby Ver Mensaje
Código PHP:
Ver original
  1. // Esto está mal
  2. $idvendedor             = $_GET["idvendedor"];
  3. if(!empty($idvendedor))
  4. {
  5.  $sql .= " WHERE e.idvendedor = ".$idvendedor;
  6. }
  7.  
  8. // Debería ser algo como:
  9. $idvendedor = false;
  10. if(isset($_GET["idvendedor"])) {
  11.     $idvendedor = $_GET["idvendedor"];
  12.     // Aquí necesitas validar que el valor sea lo que esperas
  13.     // Ya sea numérico, alfanumérico, etc.
  14.     // Y que el vendedor realmente existe
  15. }

Qué obtienes en echo $sql; ?, prueba la consulta en PhpMyAdmin y dinos si funciona o no.
  #5 (permalink)  
Antiguo 29/01/2013, 15:47
Avatar de Simon_Echecopar  
Fecha de Ingreso: marzo-2012
Mensajes: 96
Antigüedad: 12 años, 1 mes
Puntos: 0
Respuesta: Presentacion de datos

Vuelvo a poner el codigo con algunos cambios que funcionan. Me sale un Resource id #4.
Código PHP:
$sql        = "SELECT idvendedor, llavesocio, nombrevend, cvesocio, telvend, celvend, emailvend, e.FecAlta, e.fecbaja FROM cat_vendedores";
$idvendedor = $_REQUEST["idvendedor"];
if(!empty($idvendedor))
{
 $sql .= " WHERE e.idvendedor = ".$idvendedor;
 $resultado1 = mysql_query($sql,$link);
 $row1 = mysql_fetch_row($resultado1);
 
 $sql2= "SELECT idarea FROM cat_vendedores WHERE idvendedor = $idvendedor;
 $resultado2 = mysql_query($sql2,$link);
 $row2         = mysql_fetch_row($resultado2);

 $sql3 = "SELECT desc_area FROM areas WHERE id_area = ".$row2[0];
 $resultado3 = mysql_query($sql3,$link);
 $row3= mysql_fetch_row($resultado3);
 }

if(isset($_REQUEST["Busqueda"]))
{
 $vUsuario  = $_POST["vUsuario"];
 $vNombre  = $_POST["vNombre"];
 $vTelefono = $_POST["vTelefono"];
 $vCelular       = $_POST["vCelular"]; 
 $vEmail       = $_POST["vEmail"];
 $vNomArea= $_POST["vNomArea"];
 $vBaja       = $_POST["vBaja"];
 $vAlta       = $_POST["vAlta"];
 if(empty($idvendedor))
 { $idSQL= "SELECT idvendedor FROM cat_vendedor ";$count=0;$sql .= " WHERE ";  if(!empty($vUsuario)) { $count++;if($count>1) $sql .= "AND "; $sql .= " llavesocio LIKE '".$vUsuario."'"; } if(!empty($vNombre)){ $count++;if($count>1) $sql .= " AND ";$sql .= " nombrevend LIKE '".$vNombre."'"; }if(!empty($vContrasenia)){ $count++; if($count>1)$sql .= "AND "; $sql .= " cvesocio LIKE '".$vContrasenia."'"; } if(!empty($vTelefono)){
   $count++;  if($count>1)    $sql .= " AND "; $sql .= "telvend = ".$vTelefono;} if(!empty($vCelular))
  {$count++;if($count>1)$sql .= " AND "; $sql .= "celvend = ".$vCelular;}if(!empty($vEmail)) {$count++;if($count>1) $sql .= " AND "; $sql .= "emailvend = '".$vEmail."'"; }
  if(!empty($vNomArea)){ $count++;
   $sAre = "SELECT id_area FROM areas WHERE desc_area LIKE '".$vNomArea."'";
   $reAre = mysql_query($sAre); $roAre = mysql_fetch_row($reAre); if($count>1) $sql .= " AND "; $sql .= "idarea = ".$roAre[0]; }
  if(!empty($vBaja)){ $count++; if($count>1) $sql .= " AND "; $sql .= "fecbaja = '".$vBaja."'";} if(!empty($vAlta))
  { $count++;
   if($count>1)
    $sql .= " AND ";
   $sql .= "FecAlta = '".$vAlta."'";
  }//11
  echo $sql;
 }//2
 $idSQL .= $sql;
 echo $idSQL;
 $resultado2 = mysql_query($idSQL,$link);
 //header("Refresh: X; URL=www.sitios-asgui.com/crisa/abcEmpleado.php");
}//1
if(!empty($idvendedor)){
 $sql .= " WHERE idvendedor=".$idvendedor;
 $sql1= "UPDATE cat_vendedores SET ";

 $count=0;
 if(!empty($vUsuario))
 {
  $count++;
  if($count>1)
   $sql1 .= ", ";
  $sql1 .= " llavesocio = '".$vUsuario."'";

 }

 if(!empty($vContrasenia))
 {
  $count++;
  if($count>1)
   $sql1 .= ", ";
  $sql1 .= " cvesocio = '".$vContrasenia."'";

 }

 if(!empty($vNombre))
 {
  $count++;
  if($count>1)
   $sql1 .= ", ";
  $sql1 .= " nombrevend = '".$vNombre."'";
 }
 
 if(!empty($vTelefono))
 {
  $count++;
  if($count>1)
   $sql1 .= ", ";
  $sql1 .= "telvend = ".$vTelefono;
  //echo $sql."<br>";
 }
 
 if(!empty($vCelular))
 {
  $count++;
  if($count>1)
   $sql1 .= ", ";
  $sql1 .= "celvend = ".$vCelular;
 }
 
 if(!empty($vEmail))
 {
  $count++;
  if($count>1)
   $sql1 .= ", ";
  $sql1 .= "emailvend = '".$vEmail."'";

 }

 if(!empty($vNomArea))
 {
  $count++;
  $sAre = "SELECT id_area FROM areas WHERE desc_area = '".$vNomArea."'";
  $reAre = mysql_query($sAre);
  $roAre = mysql_fetch_row($reAre);

  if($count>1)
   $sql .= ", ";
  $sql .= "idarea = ".$roAre[0];

 }

 if(!empty($vBaja)){  $count++;  if($count>1)   $sql1 .= ", ";  $sql1 .= "fecbaja = '".$vBaja."'"; } if(!empty($vAlta)) { $count++; if($count>1)   $sql1 .= ", ";  $sql1 .= "FecAlta = '".$vAlta."'";}$sql1.= " WHERE idvendedor=".$idvendedor;
 
 $resultado1 = mysql_query($sql1,$link);

$resultado = mysql_query($sql,$link);
include ("seguridad.php");
require ("clase_mysql.inc.php"); ?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" lang="en">
<head>
  <meta http-equiv="content-type" content="text/html; charset=UTF8" />
  <!--<meta http-equiv="content-type" content="text/html; charset=ISO-8859-1" />-->
  <link rel="stylesheet" type="text/css" media="screen,projection,echo" href="./css/layout1a_setup.css" />
  <link rel="stylesheet" type="text/css" media="screen,projection,echo" href="./css/layout1a_text.css" />
  <title>S&iacute;stema de Facturaci&oacute;n Asgui </title>
</head>
<!-- Global IE fix to avoid layout crash when single word size wider than column width -->
<!--[if IE]><style type="text/css"> body {word-wrap: break-word;}</style><![endif]-->
<body>
 <center>
  <!-- Main Page Container -->
  <div class="page-container">
    <!-- For alternative headers START PASTE here -->
    <!-- A. HEADER -->      
    <div class="header">
      <!-- A.2 HEADER MIDDLE -->
      <div class="header-middle">    
        <!-- Site message -->
      </div>
      <!-- A.3 HEADER BOTTOM -->
      <div class="header-bottom">
        <!-- Navigation Level 2 (Drop-down menus) -->
        <div class="nav2">
            <p align="right">Usuario: <b><? echo $_SESSION["nombresocio"];?></b>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</p>
            <? include 'barramenu.php'?>  
        </div>
      </div>
    </div>
    <!-- For alternative headers END PASTE here -->
    <!-- B. MAIN -->
    <div class="main">
      <!-- B.1 MAIN CONTENT -->
      <div class="main-content">
        <hr class="clear-contentunit" />
        <h1 class="block"><center>Usuarios del Sistema</center></h1> 
        <!-- Comienza código -->
     <form method="POST" action="abcEmpleado.php"> 
      <input type="hidden" name="idarea1" value="<?php echo $idarea1?>">
      <input type="hidden" name="idvendedor" value="<?php echo $idvendedor?>">
      <table border=0>
       <tr>
        <th class="top" scope="col" width="90">Usuario</th>
        <th><input type="text" name="vUsuario" value = "<?php echo $row1[1]; ?>" size="100"></td>
       </tr>
       <tr>
        <th class="top" scope="col" width="90">Nombre</th>
        <th><input type="text" name="vNombre" value = "<?php echo $row1[2]; ?>" size="100"></td>
       </tr>
       <tr>
        <th class="top" scope="col" width="90">Contrase&ntilde;a</th>
        <th><input type="text" name="vContrasenia" value = "<?php echo $row1[3]; ?>" size="100"></td>
       </tr>
       <tr>
        <th class="top" scope="col" width="90">Telefono</th>
        <th><input type="text" name="vTelefono" value = "<?php echo $row1[4]; ?>" size="100"></td> 
       </tr>
       <tr>
        <th class="top" scope="col" width="90">Celular</th>
        <th><input type="text" name="vCelular" value = "<?php echo $row1[5]; ?>" size="100"></td>
       </tr>
       <tr>
        <th class="top" scope="col" width="90">e-mail</th>
        <th><input type="text" name="vEmail" value = "<?php echo $row1[6]; ?>" size="100"></td>
       </tr>
       <tr>
        <th class="top" scope="col" width="90">Nombre de Area</th>
        <th><input type="text" name="vNomArea" value = "<?php echo $row3[0]; ?>" size="100"></td>
       </tr>
       <tr>
        <th class="top" scope="col" width="90">Fecha Alta</th>
        <th><input type="text" name="vAlta" value = "<?php echo $row1[7]; ?>" size="100"></td>
       </tr>
       <tr>
        <th class="top" scope="col" width="90">Fecha Baja</th>
        <th><input type="text" name="vBaja" value = "<?php echo $row1[8]; ?>" size="100"></td>
       </tr>
       <tr>
        <th></td>
        <td align=right><input type="submit" id="Busqueda" name="Busqueda" value="<?php if(!empty($idvendedor)) echo "Modificar"; else echo "Buscar";?>"></td>
       </tr>
      </table>
     </form>
     <form method="GET" action="abcEmpleado.php">
     <table>
      <tr>
        <th class="top" scope="col" width="30">ID:</th>
        <th class="hpedidotit" scope="col" width="60">Usuario</th>
        <th class="hpedidotit" scope="col" width="60">Nombre</th>
        <th class="hpedidotit" scope="col" width="60">Contrase&ntilde;a</th>
        <th class="hpedidotit" scope="col" width="65">Telefono</th>
        <th class="hpedidotit" scope="col" width="70">Celular</th>
        <th class="hpedidotit" scope="col" width="130">Email</th>
        <th class="hpedidotit" scope="col" width="80">Area</th>
        <th class="hpedidotit" scope="col" width="90">Acciones</th>
        <th class="hpedidotit" scope="col" width="60">Fecha de Alta</th>
        <th class="hpedidotit" scope="col" width="60">Fecha de Baja</th>
      </tr>
      <?PHP
        
//var_dump($row=mysql_fetch_row($resultado));
      
        
while ($row=mysql_fetch_row($resultado)) // recorre los clientes uno por uno hasta el fin de la tabla
        
{
          
$SQLnomArea 'SELECT desc_area FROM areas WHERE id_area = (SELECT idarea FROM cat_vendedores WHERE idvendedor = '.$row[0].')';
          
$resultado2 mysql_query($SQLnomArea,$link);
          
$fila2=mysql_fetch_row($resultado2); 
          echo 
'<tr><td class="'.$clase_celda.'"><a id="id" name="id" href="abcEmpleado.php?idvendedor='.$row[0].'">'.$row[0].'</a></td>';
          echo 
'<td class="'.$clase_celda.'" >'.$row[1].'</td>';
          echo 
'<td class="'.$clase_celda.'" >'.$row[2].'</td>';
          echo 
'<td class="'.$clase_celda.'" >'.$row[3].'</td>';
          echo 
'<td class="'.$clase_celda.'" >'.$row[4].'</td>';
          echo 
'<td class="'.$clase_celda.'" >'.$row[5].'</td>';
          echo 
'<td class="'.$clase_celda.'" >'.$row[6].'</td>';
          echo 
'<td class="'.$clase_celda.'" >'.$fila2[0].'</td>';
          echo 
'<td class="'.$clase_celda.'" >'.''.'</td>';
          echo 
'<td class="'.$clase_celda.'" >'.$row[7].'</td>';
          echo 
'<td class="'.$clase_celda.'" >'.$row[8].'</td>';
         }
?>
     </table>
     </form>
   </div>
  </div>
  </center>
 </body>
</html>
<?php 
mysql_free_result
($resultado);
mysql_free_result($resultado1);
mysql_free_result($resultado2);
mysql_free_result($reAre);
?>
  #6 (permalink)  
Antiguo 29/01/2013, 16:19
Avatar de Triby
Mod on free time
 
Fecha de Ingreso: agosto-2008
Ubicación: $MX->Gto['León'];
Mensajes: 10.106
Antigüedad: 15 años, 8 meses
Puntos: 2237
Respuesta: Presentacion de datos

$idvendedor = $_REQUEST["idvendedor"]; es exactamente lo mismo que $idvendedor = $_GET["idvendedor"]; y no te va a solucionar las cosas, si idvendedor no fue proporcionado en la URL entonces vas a recibir un mensaje de error (o advertencia), por favor modifica esa parte como te sugerí en el mensaje anterior.


Yo sigo viendo la posibilidad de que haya dos o más " WHERE " en tu consulta (visto sólo supercifialmente), te sugiero que hagas lo siguiente:

Código PHP:
Ver original
  1. // Inicializas tu cadena
  2. $sql = 'SELECT * FROM tabla';
  3.  
  4. // Creas un arreglo para ir guardando los filtros necesarios
  5. $filtros = array();
  6.  
  7. // Analizas cada variable que pueda ser usada como filtro
  8. if($idVendedor != 0) {
  9.     $filtros[] = "idvendedor = $idVendedor";
  10. }
  11.  
  12. if($otraVariable != '') {
  13.     $filtros[] = "nombre_de_campo = '$otraVariable'";
  14. }
  15.  
  16. // Al final, sólo revisas si hay filtros y los agregas
  17. if(count($filtros) > 0) {
  18.       $sql .= ' WHERE ' . implode(' AND ', $filtros);
  19. }
  20.  
  21. // Esta consulta debe estar correcta
  22. // O puedes copiarla y pegarla en PhpMyAdmin para probarla ahí
  23. echo $sql;
__________________
- León, Guanajuato
- GV-Foto
  #7 (permalink)  
Antiguo 29/01/2013, 16:39
Avatar de Simon_Echecopar  
Fecha de Ingreso: marzo-2012
Mensajes: 96
Antigüedad: 12 años, 1 mes
Puntos: 0
Respuesta: Presentacion de datos

ok, gracias lo intentare.

Etiquetas: html, mysql, presentacion, select, sql, tabla, usuarios
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 13:53.