TalkPHP
 
 
Account Login
Latest Articles
» The basic usage of PHPTAL, a XML/XHTML template library for PHP
» Vulnerable methods and the areas they are commonly trusted in.
» Simple way to protect a form from bot
» The Basics On: How Session Stealing Works
» How to keep your forms from double posting data
IRC Channel
IRC Speech Bubble Join the friendly bunch on IRC...
(#TalkPHP on Freenode)

...Also available via a web interface.

See this thread for information on the TalkPHP Free Hugs Initiative™. Subject to availability.
Associates
Associates
CSS Tutorials
Reply
 
LinkBack Thread Tools Search this Thread Display Modes
Old 02-11-2010, 08:16 PM   #1 (permalink)
The Contributor
 
marxx's Avatar
 
Join Date: Sep 2007
Location: Finland
Posts: 45
Thanks: 3
marxx is on a distinguished road
Default 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!
Send a message via MSN to marxx
marxx is offline  
Reply With Quote
Reply



Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On

Similar Threads
Thread Thread Starter Forum Replies Last Post
Count file in dir with matching $string at a line $var... Peuplarchie Advanced PHP Programming 1 12-11-2008 03:09 AM
Page Load Count Wildhoney Script Giveaway 1 03-25-2008 05:48 AM
Blogs, blogs, and more blogs Alan @ CIT The Lounge 6 02-27-2008 11:10 PM
MySQL Count and PHP crazyryan Absolute Beginners 19 12-09-2007 05:48 PM
Count multiple tables + same row name marxx General 1 09-26-2007 12:44 PM


All times are GMT. The time now is 06:36 AM.

 
     

Powered by vBulletin® Version 3.6.8
Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.
Search Engine Optimization by vBSEO 3.1.0
Inactive Reminders By Icora Web Design