homepage Welcome to WebmasterWorld Guest from 54.198.33.96
register, free tools, login, search, pro membership, help, library, announcements, recent posts, open posts,
Become a Pro Member

Home / Forums Index / Code, Content, and Presentation / Databases
Forum Library, Charter, Moderators: physics

Databases Forum

    
PHP/MYSQL searching text entries
programming blog system - need help with search
Clair




msg:3308261
 11:14 am on Apr 11, 2007 (gmt 0)

Hi--
Am creating a simple blog system for my use. So far progress has been good. Here's what I have:

MySQL Table with ID, Title, Content, Date

Enter new blog.
Add blog to displayed list as link.
Call up specific blog from above list--edit it and save it.

That's all well an good for me as the blogger. What I am stumped on is how best to search the contents of the Content item, when a visitor enters a keyword (or keywords) and return links to *only* those blogs that match the search words.

Any pointers much appreciated.

Thanks,
Clair

 

justageek




msg:3308411
 2:12 pm on Apr 11, 2007 (gmt 0)

Use a fulltext index. It will index fullwords in the content and is fairly fast. That sounds like what you are looking for.

JAG

Clair




msg:3308539
 4:31 pm on Apr 11, 2007 (gmt 0)

JAG --
Yeesh - three PHP / MySQL books and nothing about something called FULLTEXT. Will hit google for that BUT, in the meantime -- I'm having trouble with my query -- but it is so close it hurts.

Here's the one-line form that feeds the query:

<form action="search-blog.php" method="post">
<p>Search for: <input type="text" name="searchword" size="40" maxsize="100" /></p>
<input type="submit" name="submit" value="Go find!" />
</form>

And here's the query that has a syntax problem:

$query = "SELECT * FROM blog_entries WHERE MATCH
(blog_entry={$_GET['entry']}) AGAINST (searchterm={$_POST['searchword']})";

and here's the Error Msg.:

Check the manual that corresponds to your MySQL server version for the right syntax to use near '=) AGAINST (searchterm=testing)' at line 2. The query was SELECT * FROM blog_entries WHERE MATCH (blog_entry=) AGAINST (searchterm=testing).

Note: "testing" was a word I entered into the form.

I know this query is not what I finally want, but it would be useful at some point, it I could get this working.

Thanks much. I've pored over this character by character until I'm blue in the face! lol

Clair

justageek




msg:3308557
 4:49 pm on Apr 11, 2007 (gmt 0)

SELECT * FROM blog_entries WHERE MATCH (blog_entry=) AGAINST (searchterm=testing)

I usually use boolean mode so I'd use:

SELECT * FROM blog_entries WHERE MATCH (blog_entry) AGAINST ('+"testing"' in boolean mode)

That should work for you as long as the fulltext index is there.

JAG

Clair




msg:3308640
 6:31 pm on Apr 11, 2007 (gmt 0)

Hi justageek and Jag --

Just came back to tell you that I had everything working with FULLTEXT --
and found just's comment. Thanks!

I found the FULLTEXT help via Zend Developer and the got the query string sorted out with the help of phpfreaks.

Not bad -- whole thing working inside 1 hour (had lunch in the middle!)

Man, I am one happy camper.

Cheers,
Clair

justageek




msg:3308680
 7:09 pm on Apr 11, 2007 (gmt 0)

Very good!

JAG

Clair




msg:3308867
 10:37 pm on Apr 11, 2007 (gmt 0)

lol
JAG --
I was so excited when I came back in to report success that I read Justageek in the side bar and thought it was a second person.

See - you can be in two places at once, or else beside yourself -- which was the case here.

Thanks JAG and only JAG -
Clair

justageek




msg:3308911
 11:47 pm on Apr 11, 2007 (gmt 0)

See - you can be in two places at once, or else beside yourself -- which was the case here

:-) We're ALL here to help!

JAG

Global Options:
 top home search open messages active posts  
 

Home / Forums Index / Code, Content, and Presentation / Databases
rss feed

All trademarks and copyrights held by respective owners. Member comments are owned by the poster.
Home ¦ Free Tools ¦ Terms of Service ¦ Privacy Policy ¦ Report Problem ¦ About ¦ Library ¦ Newsletter
WebmasterWorld is a Developer Shed Community owned by Jim Boykin.
© Webmaster World 1996-2014 all rights reserved