TalkPHP

TalkPHP (http://www.talkphp.com/forums.php)
-   General (http://www.talkphp.com/general/)
-   -   Count how many blogs has this tag? (http://www.talkphp.com/general/5264-count-how-many-blogs-has-tag.html)

marxx 02-11-2010 08:16 PM

Count how many blogs has this tag?
 
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!


All times are GMT. The time now is 05:21 AM.

Powered by vBulletin® Version 3.6.8
Copyright ©2000 - 2013, Jelsoft Enterprises Ltd.
Search Engine Optimization by vBSEO 3.1.0