I'm trying to get the value of comma separated string.
Ex string: apple, google, yahoo, stackover flow
code:
$arr=explode(",",$Tags);
foreach ($arr as $TagValue) {
$ShowTags = strtolower($TagValue);
echo '<ul class="tags">
<li><a href="tags.php?tag='.$ShowTags.'">'.$TagValue.'</a></li>
</ul>';
}
MySQL
$tag = $_GET['tag'];
SELECT FROM posts WHERE active=1 and (tags LIKE '$tag%') ORDER BY id DESC
Issue is it is displaying 1st value (Ex: apple from the above mention) But none of the other values are getting displayed. Can someone tell me how to do this?
I found the issue. I should add '%$tag%' instead of '$tag%'. This fixed the issue.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.