Ver Mensaje Individual
  #1 (permalink)  
Antiguo 13/10/2012, 07:01
gusanosxr
 
Fecha de Ingreso: junio-2012
Ubicación: Santiago de Chile
Mensajes: 164
Antigüedad: 11 años, 10 meses
Puntos: 1
dudas con consulta where like

Resulta que tengo esta consulta pero no me funka bien

Código PHP:


<?
$area 
$_POST["area"];
$rut $_POST["rut"];

if (
$area!='' || $rut!=''){

if (
$area==0){$extension="_usadospesados";}
if (
$area==2){$extension="_fordcamiones";}
if (
$area==8){$extension="_fortaleza";}
if (
$area==9){$extension="_hyundai";}
if (
$area==10){$extension="_global";}
if (
$area==11){$extension="_usadosliv";}
if (
$area==14){$extension="_fliv";}

echo(
"<table class=titulo width=900 border=1>");
      echo(
"<tr>");
      echo(
"  <td><h6>Ver</td>");
      echo(
"  <td><h6>Rut</td>");
      echo(
"  <td><h6>Nombre</td>");
      echo(
"  <td><h6>Fono</td>");
      echo(
"  <td><h6>Fono2</td>");
      echo(
"  <td><h6>Celular</td>");
      echo(
"  <td><h6>Correo</td>");
      echo(
"  <td><h6>Comuna</td>");
      echo(
"  <td><h6>Direccion</td>");
      echo(
"</tr>");
include 
"conectar.php";
$consulta "SELECT * FROM solicitud_credito WHERE area_usuario=".$area;
if (
$rut!=''){$consulta=$consulta." and rut_cliente like '"%.$rut.%"'";}
$consulta=$consulta." order by numero DESC";
$result mysql_query($consulta);
if (
mysql_num_rows($result)>0){
   
$i=0;
   
$rows=mysql_num_rows($result);
   while(
$i $rows) {
      echo(
"<tr>");
      echo(
"<td><a href=ver_cliente.php?num=".mysql_result($result$i"num_cliente").">Ver</a></td>");
      echo(
"<td width=100>".mysql_result($result$i"rut_cliente")."</td>");
      echo(
"<td>".mysql_result($result$i"cliente")."</td>");
      
$result2 mysql_query("SELECT * FROM empresa".$extension." WHERE Numero=".mysql_result($result$i"num_cliente"));
      if (
mysql_num_rows($result2)>0){
      
$x=0;
         echo(
"<td>".mysql_result($result2$x"fono1")."</td>");
         echo(
"<td>".mysql_result($result2$x"fono2")."</td>");
         echo(
"<td>".mysql_result($result2$x"celular")."</td>");
         echo(
"<td>".mysql_result($result2$x"email_personal")."</td>");
         echo(
"<td>".mysql_result($result2$x"comuna")."</td>");
         echo(
"<td>".mysql_result($result2$x"Direccion")."</td>");
      }else{
      echo(
"<td></td>");
      }
      
$x++;
      echo(
"</tr>");
   
$i++;
   }
}
echo(
"</table>");
}
?>

EL PROBLEMA ESTÁ DONDE A LA CONSULTA LE AGREGO EL LIKE "%$RUT%", LO INTENTÉ DE MUCHAS FORMAS, PONIENDO COMILLAS Y SACANDOLAS, PERO NADA RESULTA...AYUDAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA