Nomax5 Posted September 11, 2006 Share Posted September 11, 2006 I'm coding a website link management thing I'm storing website details: url, title, description, and keywords. What I want to be able to do is identify releated websites. it doesn't have to be perfect I present them to the visitors as "possibley related websites"My initial idea was put the keywords in seperate fields and to do multiple searches one keyword at a time.but I'm thinking perhaps I should create a full-text index and do something better.perhaps seach the title and the description also suppose I had a string of keywords "fish,fishing,fish scales,fish tail, shark,fishing rod"You guys are usually really good at comming up with ideas, I thought I'd ask for your ideas before I build the tablesCheersRoy Quote Link to comment https://forums.phpfreaks.com/topic/20429-best-way-for-store-and-find-keyword-matches-php-mysql/ Share on other sites More sharing options...
Ninjakreborn Posted September 11, 2006 Share Posted September 11, 2006 I normally do these open searches. Like I have a form[code]<form name="searchform" id="searchform" action="whatever.php" method="get or post"><label for="searchtext">Search</label><input name="searchtext" id="searchtext" type="text" maxlength="120" /><br /><input name="searchsubmit" id="searchsubmit" type="submit" value="Search It!" /></form>[/code]THen you can process it, and when you do, run a special query, with the query have it check everyfield of everydatabase. With 2 percentages, this makes it guarantee any close match, for any field.Like this[code]<?php$search = mysql_real_escape_string($_GET['searchtext']);$search = strtolower($search);$select = "SELECT * FROM tablename WHERE url LIKE '%$search' OR title LIKE '%$search' OR description LIKE '%$search' OR keywords LIKE '%$search';";$query = mysql_query($select);if ($row = mysql_fetch_array($query)) {// do whatever }?>[/code] Quote Link to comment https://forums.phpfreaks.com/topic/20429-best-way-for-store-and-find-keyword-matches-php-mysql/#findComment-90110 Share on other sites More sharing options...
Nomax5 Posted September 12, 2006 Author Share Posted September 12, 2006 ahh thanks businessman332211 I'll fiddle with it. Quote Link to comment https://forums.phpfreaks.com/topic/20429-best-way-for-store-and-find-keyword-matches-php-mysql/#findComment-90310 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.