ctcp Posted July 20, 2009 Share Posted July 20, 2009 <? $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 More sharing options...
patrickmvi Posted July 20, 2009 Share Posted July 20, 2009 The first thing I would notice is that it looks like you're missing a starting { after your while loop. However, you need to be specific about the issue that you are having in order to recieve some help. Link to comment https://forums.phpfreaks.com/topic/166621-php-result-help/#findComment-878614 Share on other sites More sharing options...
ctcp Posted July 20, 2009 Author Share Posted July 20, 2009 <?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 More sharing options...
ctcp Posted July 20, 2009 Author Share Posted July 20, 2009 bump Link to comment https://forums.phpfreaks.com/topic/166621-php-result-help/#findComment-878687 Share on other sites More sharing options...
mattal999 Posted July 20, 2009 Share Posted July 20, 2009 Add this and tell us the result: mysql_query($query) or die(mysql_error()); Link to comment https://forums.phpfreaks.com/topic/166621-php-result-help/#findComment-878704 Share on other sites More sharing options...
ctcp Posted July 20, 2009 Author Share Posted July 20, 2009 select * from google WHERE topic LIKE '%a%' order by date DESC LIMIT 0, 2You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'limit 0,2' at line 1 Link to comment https://forums.phpfreaks.com/topic/166621-php-result-help/#findComment-878709 Share on other sites More sharing options...
mattal999 Posted July 20, 2009 Share Posted July 20, 2009 <?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 More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.