Jump to content

php result help


ctcp

Recommended Posts

<?
  $var1 = @$_GET['q1'] ;
  $var2 = @$_GET['q2'] ;
  $var3 = @$_GET['q3'] ;
  $var4 = @$_GET['q4'] ;
  $trimmed1 = trim($var1);
  $trimmed2 = trim($var2);
  $trimmed3 = trim($var3);
  $trimmed4 = trim($var4); 
  
if(trimmed1 || $trimmed2 || $trimmed3 || $trimmed4) {
       $query = "select * from google WHERE ";
   if($trimmed1  !='') { $query .= " topic LIKE '%$trimmed1%' AND"; }
   if($trimmed2  !='') { $query .= " upload LIKE '%$trimmed2%' AND "; }
   if($trimmed3  !='') { $query .= " type LIKE '%$trimmed3%' AND "; }
   if($trimmed4  !='') { $query .= " date LIKE '%$trimmed4%' "; }
   if(substr($query, strlen($query)-4, 4) == ' AND') {   $query = substr($query, 0, strlen($query)-4); }
               $query .= " order by date asc";


while ($data = mysql_fetch_array($results)) 

?>
<a href="<?=$data["url"]?> "target="_blank"> <?=$data["topic"]?> </a> <div class="url1">[<?=$data["forum_name"]?>]</div>
<div class="url2">
[<?=$data["type"]?>] - <?=$data["date"]?><br>
<?=$data["upload"]?>
</div>
<div class="url">
<?=$data["url"]?><br>
</div><br>

<?
} 
?>

 

can sombady help me what is wrong here ?

 

Link to comment
https://forums.phpfreaks.com/topic/166621-php-result-help/
Share on other sites

<?php 
if(trimmed1 || $trimmed2 || $trimmed3 || $trimmed4) {
       $query = "select * from google WHERE ";
   if($trimmed1  !='') { $query .= " topic LIKE '%$trimmed1%' AND"; }
   if($trimmed2  !='') { $query .= " upload LIKE '%$trimmed2%' AND "; }
   if($trimmed3  !='') { $query .= " type LIKE '%$trimmed3%' AND "; }
   if($trimmed4  !='') { $query .= " date LIKE '%$trimmed4%' "; }
   if(substr($query, strlen($query)-4, 4) == ' AND') {   $query = substr($query, 0, strlen($query)-4); }
               $query .= " order by date DESC ";
echo $query; //
?>

 

this working fine

but i whant add $limit and $page and not working ...

<?php
if(trimmed1 || $trimmed2 || $trimmed3 || $trimmed4) {
       $query = "select * from google WHERE ";
   if($trimmed1  !='') { $query .= " topic LIKE '%$trimmed1%' AND"; }
   if($trimmed2  !='') { $query .= " upload LIKE '%$trimmed2%' AND "; }
   if($trimmed3  !='') { $query .= " type LIKE '%$trimmed3%' AND "; }
   if($trimmed4  !='') { $query .= " date LIKE '%$trimmed4%' "; }
   if(substr($query, strlen($query)-4, 4) == ' AND') {   $query = substr($query, 0, strlen($query)-4); }
               $query .= " order by date DESC LIMIT $page, $limit";
echo $query; // 
?>

 

LIMIT $page, $limit

 

 

select * from google WHERE topic LIKE '%a%' order by date DESC LIMIT 0, 2Couldn't execute query

Link to comment
https://forums.phpfreaks.com/topic/166621-php-result-help/#findComment-878653
Share on other sites

<?php

if(trimmed1 || $trimmed2 || $trimmed3 || $trimmed4) {
    $query = "SELECT * FROM google WHERE ";
    if($trimmed1  !='') { $query .= " topic LIKE '%$trimmed1%' AND"; }
    if($trimmed2  !='') { $query .= " upload LIKE '%$trimmed2%' AND "; }
    if($trimmed3  !='') { $query .= " type LIKE '%$trimmed3%' AND "; }
    if($trimmed4  !='') { $query .= " date LIKE '%$trimmed4%' "; }
    if(substr($query, strlen($query)-4, 4) == ' AND') {
        $query = substr($query, 0, strlen($query)-4); 
    }
    $query .= " ORDER BY date DESC LIMIT $page, $limit";
    echo $query."<br />";
    mysql_query($query) or die(mysql_error());
}

?>

 

See what that returns. I had problems with lowercase operators in MySQL.

Link to comment
https://forums.phpfreaks.com/topic/166621-php-result-help/#findComment-878765
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.