Search through comments activated Nov04 '05

Feedback

# (1 of 5): Jennifer Grucza » jennifergrucza.com

1 hour, 50 minutes after the fact. (Fri 04 Nov 2005, 1:01 PM CST)

Good work - it's definitely useful functionality, isn't it? :)

# (2 of 5): Matthom

4 hours, 19 minutes after the fact. (Fri 04 Nov 2005, 3:29 PM CST)

You bet it's useful - thanks to associative arrays, and PHP's krsort!

# (3 of 5): Dale » bluetrait.com

5 hours, 30 minutes after the fact. (Fri 04 Nov 2005, 4:40 PM CST)

Great stuff, if I get time I shall upgrade my seach to be as good as yours!

# (4 of 5): Josh » joahua.com/blog

6 hours, 5 minutes after the fact. (Fri 04 Nov 2005, 5:15 PM CST)

Hehe, yes, and I'd upgrade WordPress' search to be as good as yours if... it wasn't such an enormous piece of software and that I'd never get it merged back into CVS and hence it'd break as soon as a new version came out ;-) Actually maybe someone has written a plugin for this... hmm.

Irrespective of that, your search is cool! :P

With the array do you do one query then append the results of the second query? And then sort it? I'm noticing that the using commas example search doesn't group comments vs posts, so... sorted by relevance?

# (5 of 5): Matthom

6 hours, 31 minutes after the fact. (Fri 04 Nov 2005, 5:42 PM CST)

Josh - yes, the results are sorted by relevance, which comes from the query.

So, I have two separate queries - one that searches my blog posts, and one that searches feedback. Both queries are dealt with separately.

For both queries, I loop through the results (for), and each time through the loop, a new array item is added to an array called searchResults_array. The array item is added as an associative item, with the key being the relevance number, and the value being all of the HTML output, merged together as one string, with hash marks ( | ) designating the table cell.

Once all of the search results are pooled into the array, I then sort the array by key, in reverse order ( krsort ). The key, remember, is the relevance from the MySQL query.

After that, all that's left is to implode each array item at the hash mark, into separate table cells.

RSS feed for comments on this post

Leave feedback

Feedback

Input format: The editor controls below will assist with Markdown syntax.

Status

Sub-status

Your info

Return to entry.

matthom is published and produced by Matt Thommes - an independent publishing enthusiast, mobile blogger, content creator, informative writer, web developer from Chicago. Never one to conform, Matt intends to promote the effect the web has on our lives, in an effort to intensify, instruct, and clarify all that is happening around us.

Contact Matt

I just implemented a much better search mechanism, for this site, which searches through blog posts and feedback. Before, you could only search through posts.

You are at the feedback permalink page for: Search through comments activated

Read more...