Hi all! It has being long time when I was here but now I need again yours superb help! ;)
I need to count how many blogs has currently rolled tag in loop.
So here we go..
database
tags:
ID | TAG (tag name)
database
entries:
TAGS where tags are like (tagone tagtwo tagthree)
This is what I have now in place
Code:
foreach($tags->result() AS $tag) {
$query = $this->db->query("SELECT COUNT(id) AS count FROM entries WHERE tags LIKE '%$tag->tag%' OR tags LIKE '%$tag->tag' OR tags LIKE '$tag->tag%' OR tags = '$tag->tag'");
$cTags = $query->row();
if($cTags->count > 0) {
echo '<li><a href="' . base_url() . 'blog/tags/' . $tag->tag . '">'.$tag->tag.' ('.$cTags->count.')</a></li>';
}
}
but here if I have tag APPLE and APPLECORN but only one blog has APPLE tag, this will count that both APPLE and APPLECORN have one tags in place.. Sucks, I know! ;)
So I maybe have to explode tags from entries database? Then throw it in loop where is query to count? maybe? I don't know, thats why i'm here! :)
explodes and array are still little mystery to me. I need to push my brains out everytime I need to handle arrays before it will work (somehow anyways).
Yes, I use codeigniter where everyday learn something new but not arrays! ;)
Thanks for all help!