displaying similar queries php mysql
I am trying to make a function to show 5 related keywords for whatever search query is done. For example if someone searched for blueberry it would show 5 similar keywords such as blueberry jam, blue blueberry, blueberrys "I know that spelled incorrectly but I am just getting the point accross. So far I have came up with this but it only repeats the query keyword 5 times and I cannot figure out how to make it show the similar keywords and I also dont know if this is the best way to do this? Can anyone give me some input? thanks.
$result=mysql_query("select keyword from keywords WHERE keyword like '%{$query}%开发者_C百科' LIMIT 5"); while ($row=mysql_fetch_row($result)) echo "".($query).""
The table I am using is called keywords and the columns I need are keyword.
$result=mysql_query("select keyword from keywords WHERE keyword like '%{$query}%' LIMIT 5"); while ($row=mysql_fetch_assoc($result)) echo "". $row['keyword'] .""
Not sure what $query
is you're using, but the following should work.
$result=mysql_query("select keyword from keywords WHERE keyword like '%{$query}%' LIMIT 5");
while ($row=mysql_fetch_row($result)) { echo "".($row[0]).""; }
$result = mysql_query("select keyword from keywords WHERE keyword like '%{$query}%' LIMIT 5");
while ($row = mysql_fetch_row($result)) echo $row[0];
Edit : too late :)
精彩评论