Ver Mensaje Individual
  #6 (permalink)  
Antiguo 08/02/2009, 20:10
warbandit69
 
Fecha de Ingreso: diciembre-2008
Ubicación: http://www.solucionesrios.tk/
Mensajes: 413
Antigüedad: 15 años, 4 meses
Puntos: 19
Respuesta: Problemas con sonsulta SQL con matriz e implode en PHP

Ok, luego de leer un poco, modifique el codigo, espero este bien, no lo se, porque cada vez que se va a ejecutar el script me tumba el Apache, que les parece?

Código PHP:
<?php virtual('/Activos2/Connections/activos.php'); ?>
<!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>Sistema de Inventario MyA</title>
</head>
<body>
<?php
$cedula 
$_POST['cedula'];
$nombre $_POST['nombre'];
$cargo $_POST['cargo'];

$cedula mysql_real_escape_string($cedula);
$nombre mysql_real_escape_string($nombre);
$cargo mysql_real_escape_string($cargo);

if(
$cedula="")

$where_cedula "%";
}
if(
$nombre="")

$where_nombre "%";
}
if(
$cargo="")

$where_cargo "%";
}

if(isset(
$cedula) && $cedula!="")
{
$where_cedula " cedula LIKE '%".$cedula."%'";
}
if(isset(
$nombre) && $nombre!="")
{
$where_nombre " nombre LIKE '%".$nombre."%'";
}
if(isset(
$cargo) && $cargo!="")
{
$where_cargo " nombre LIKE '%".$cargo."%'";
}

$where_array = array($where_cedula$where_nombre$where_cargo);
$where implode(" AND "$where_array);

$query "SELECT * FROM responsable WHERE ".$where." ORDER BY cedula";  // Esta es la linde adonde tengo problemas

$result mysql_query($query);

if(!
$result)
{
    exit(
"hay un error con la consulta : ".mysql_error());
}
else
{
echo 
"<table width=100% border=1 cellspacing=1 cellpadding=1><tr bgcolor=#009900 align=center><td><div align=center>
<em><strong>C&Eacute;DULA</strong></em></div></td><td><div align=center>
<em><strong>NOMBRE</strong></em></div></td><td><div align=center>
<em><strong>CARGO</strong></em></div></td></tr>"
;
while(
$row mysql_fetch_array ($result))
{
echo 
"<TR>
<TD WIDTH=5% ALIGN=CENTER>$row[cedula]</TD>
<TD WIDTH=10% ALIGN=center>$row[nombre]</TD>
<TD WIDTH=20% ALIGN=CENTER>$row[cargo]</TD>
</TR>"
;
}
echo 
"</TABLE></form>";
}

mysql_free_result($result);
include 
"desconectarse.php"



?>
<div align="center">
  <p>&nbsp;</p>
  <p><a href="/Activos2/busqueda_responsables.php">Regresar/Nueva Búsqueda</a></p>
</div>
</body>
</html>
<?php
mysql_free_result
($result);
?>