Forum Moderators: coopster

Message Too Old, No Replies

Search in descriptions by 1 or 2 words

match against or similar text functions

         

rowtc2

10:03 am on Nov 30, 2008 (gmt 0)

10+ Year Member



I have some products with descriptions. For each product i have some tag words

ex. description: Texas is located in the south of united states
tag1 texas -return results
tag2 united states -return results
tag3 south states - Do Not return results

I want to return results even the 2 words are not in descriptions in exact order, or to return results for at least 1 term from this tag3.

I have tried


$sql = "select * from produs WHERE MATCH (description) AGAINST ('nume_tag') ORDER BY views DESC LIMIT 20";

and similar_text from php site,but with errors.I dont know php,if you can help me with a code snippet in my actually code will be appreciated.

Now i am using this code:

<?php 
$dbhost = "localhost";
$dbname = "nameG";
$dbuser = "usernameG";
$dbpasswd = "passwordG";
$prefix = "";
if(!$db = @mysql_connect("$dbhost", "$dbuser", "$dbpasswd"))
die('<font size=+1>An Error Occurred</font><hr>Unable to connect to the database. <BR>Check $dbhost, $dbuser, and $dbpasswd in config.php.');
if(!@mysql_select_db("$dbname",$db))
die("<font size=+1>An Error Occurred</font><hr>Unable to find the database <b>$dbname</b> on your MySQL server.");
?>

<html>
<head>
<title> </title>
<meta name="description" content=" " >
<meta name="Keywords" CONTENT="">
</head>
<body>

<?

$nume_tag = $row["nume_tag"];

$sql = "select * from produs WHERE description LIKE '%$nume_tag%' ORDER BY views DESC LIMIT 20";
$result = mysql_query ($sql);
while($row = mysql_fetch_array($result)){

$doc_id=$row["doc_id"];
$titlu = $row["titlu"];
$views = $row["views"];
$description = $row["description"];

echo"

$titlu <BR>

";}?>
</body>
</html>

eelixduppy

1:45 am on Dec 9, 2008 (gmt 0)



>> ,but with errors.

What are the errors you are receiving?