http://foros.cristalab.com/problema-con-update-t108856/#657279
El caso es que tengo un login que me evia a un menu y a de ahi a una tabla que me muestra registros, necesito que en al tabla no me muestre los registros que estan en estado 8 , si publico solo la pagina de la tabla funciona perfecto, pero al entrar desde el login me muestra este error:
You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'WHERE (Estado='1' OR Estado='2' OR Estado='3' OR Estado='4' OR Estado='5' OR Est' at line 1
Y mi codigo (lo que esta dentro de la tabla) es:
Código PHP :
<table class="tabla" align="center" cellspacing="0">
<tr>
<th>ID</th>
<?php
$pageURL = 'http';
$pageURL .= "://";
if ($_SERVER["SERVER_PORT"] != "80") {
$pageURL .= $_SERVER["SERVER_NAME"].":".$_SERVER["SERVER_PORT"].$_SERVER["REQUEST_URI"];
}
else {
$pageURL .= $_SERVER["SERVER_NAME"].$_SERVER["REQUEST_URI"];
}
echo("<th><a href='");
echo($pageURL."&filtro=Cliente'");
echo(">Cliente</a></th>");
echo("<th><a href='");
echo($pageURL."&filtro=Numero'");
echo(">Numero OP</a></th>");
echo("<th><a href='");
echo($pageURL."&filtro=Tema_General'");
echo(">Tema General</a></th>");
echo("<th><a href='");
echo($pageURL."&filtro=Responsable'");
echo(">Responsable</a></th>");
echo("<th><a href='");
echo($pageURL."&filtro=Estado'");
echo(">Estado</a></th>");
?>
<th>Editar</th>
<th>Anular</th>
</tr>
//LA CONSULTA SIGUIENTE ES LA CONFLICTIVA..........
<?php
$filtrar="si";
$pedido="SELECT Numero, Cliente, Tema_General, Responsable, Estado FROM ordenes WHERE Estado <> '8'";
if(isset($_GET['buscar'])){
if($_GET['buscar']!=""){
if($filtrar=="si"){
$buscar=strtolower($_GET['buscar']);
$pedido=$pedido." WHERE (LOWER(Tema_General) like '%$buscar%' OR LOWER(Descripcion) like '%$buscar%' OR LOWER(Observaciones) like '%$buscar%')";
$filtrar="busqueda";
}
}
}
for($n=1; $n <= 11; $n++){
$n=(string) $n;
if(isset($_GET[$n])){
if($_GET[$n]==$n){
if($filtrar=="busqueda"){
$pedido=$pedido." AND (Estado='$_GET[$n]'";
$filtrar="no";
}
if($filtrar=="si"){
$pedido=$pedido." WHERE (Estado='$_GET[$n]'";
$filtrar="no";
}
else{
$pedido=$pedido." OR Estado='$_GET[$n]'";
}
}
}
}
if($filtrar=="no"){
$pedido=$pedido.")";
}
if(isset($_GET['responsable'])){
if($_GET['responsable']!="todos"){
if($filtrar=="si"){
$pedido=$pedido." WHERE Responsable='$_GET[responsable]'";
$filtrar="no";
}
else{
$pedido=$pedido." AND Responsable='$_GET[responsable]'";
$filtrar="no";
}
}
}
if(isset($_GET['filtro'])){
$pedido=$pedido." ORDER BY $_GET[filtro]";
}
$consecutivo=0;
if($_GET['filtro']=="Cliente"){
for($j=0;$j<=count($nomcliente)-1;$j++){
$result = mysql_query($pedido);
while($row = mysql_fetch_array($result)){
$clie=true;
for($i=count($nomcliente)-1; $i >= 0; $i--){
if($idcliente[$i]==$row['Cliente']){
$client=$nomcliente[$i];
$clie=false;
}
}
if($clie){
$client=$row['Cliente'];
}
if($client==$nomcliente[$j]){
$consecutivo++;
$link="modificaciones/estado.php?orden=".$row['Numero'];
echo("<tr>");
echo("<td> ");
echo $consecutivo;
echo(" </td>");
echo("<td>");
echo("<a href='".$link."'> ");
$clie=true;
for($i = count($nomcliente) -1; $i >= 0; $i--){
if($idcliente[$i]==$row['Cliente']){
echo($nomcliente[$i]);
$clie=false;
}
}
if($clie){
echo $row['Cliente'];
}
echo(" </a></td>");
echo("<td>");
echo("<a href='".$link."'> ");
echo $row['Numero'];
echo(" </a></td>");
echo("<td>");
echo("<a href='".$link."'> ");
echo $row['Tema_General'];
echo(" </a></td>");
echo("<td>");
echo("<a href='".$link."'> ");
echo $row['Responsable'];
echo(" </a></td>");
echo("<td>");
echo("<a href='".$link."'> ");
$est=$row['Estado']-1;
if($est>=0){
echo($estados[$est]);
}
else{
echo($row['Estado']);
}
echo(" </a></td>");?>
<td align="center"><a href="modificaciones/edit_orden.php?orden=<?php echo $row['Numero']; ?>"><img src='imgs/editar.png' border="0"/></a></td>
<td align="center"><a href="modificaciones/anularop.php?anular=<?php echo $orden; ?>"><img src='imgs/cerrar.png' border="0"/></a></td>
<?php
echo("</tr>");
}
}
}
}
else{
$result1 = mysql_query($pedido)or die(mysql_error());
while($row = mysql_fetch_array($result1)){
$consecutivo++;
$link="modificaciones/estado.php?orden=".$row['Numero'];
echo("<tr>");
echo("<td> ");
echo $consecutivo;
echo(" </td>");
echo("<td>");
echo("<a href='".$link."'> ");
$clie=true;
for($i = count($nomcliente) -1; $i >= 0; $i--){
if($idcliente[$i]==$row['Cliente']){
echo($nomcliente[$i]);
$clie=false;
}
}
if($clie){
echo $row['Cliente'];
}
echo(" </a></td>");
echo("<td>");
echo("<a href='".$link."'> ");
echo $row['Numero'];
echo(" </a></td>");
echo("<td>");
echo("<a href='".$link."'> ");
echo $row['Tema_General'];
echo(" </a></td>");
echo("<td>");
echo("<a href='".$link."'> ");
echo $row['Responsable'];
echo(" </a></td>");
echo("<td>");
echo("<a href='".$link."'> ");
$est=$row['Estado']-1;
if($est>=0){
echo($estados[$est]);
}
else{
echo($row['Estado']);
}
echo(" </a></td>");
?>
<td align="center"><a href="modificaciones/edit_orden.php?orden=<?php echo $row['Numero']; ?>"><img src='imgs/editar.png' border="0"/></a></td>
<td align="center"><a href="modificaciones/anularop.php?accion=anular&orden=<?php echo $row['Numero']; ?>"><img src='imgs/cerrar.png' border="0"/></a></td>
<?php
echo("</tr>");
}
}
?>
</table>Alguno me puede ayudar con esto?? Muchas gracias.
