Forum Moderators: coopster
Above is just an example the actual tags can be much longer and separated by comma
<?php
$tags = "piece1 piece2 piece3 piece4 piece5 piece6";
$pieces = explode(" ", $tags);
echo $pieces[0]; // piece1
echo $pieces[1]; // piece2 and so on But then how do i get to know how many tags are there that means $piece[5] exists but $piece[6] doesnot exist. How to know about this?
Can i use array_key_exists() to check if the tags exist in the array
and then i use a for($i=0;i<array key;i++) loop
{
SELECT DISTINCT id FROM wow WHERE 0 OR CONCAT(title,content,views,'') LIKE '%$piece[$i]%' ORDER BY id DESC;
}
Is the above logic correct? Please see the %$piece[$i]% query if it's structure/syntax is ok?
any suggestions or improvements?
<?
for($i = 0; $i<sizeof($pieces); $i++){
$query = "SELECT DISTINCT id FROM wow WHERE 0 OR CONCAT(title,content,views,'') LIKE '%".$pieces[$i]."%' ORDER BY id DESC";
}
?>
The query above works fine, but sometimes if the pieces matches with the current article, it returns the id of the article i am viewing.
How to filter the current id of the article from search results?
current id is accessed by $page