[prev in list] [next in list] [prev in thread] [next in thread] 

List:       php-db
Subject:    RE: [PHP-DB] populating <select> and searching to criteria
From:       "Shannon Doyle" <shannon () wyattgroup ! com ! au>
Date:       2003-10-28 4:46:34
[Download RAW message or body]



Thanks Micah,


while ($d = mysql_fetch_assoc($return)) {
?><option value="<?=$d['value']?>"><?=$d['name']?></option> ----- I get
a parse error on this line.

while ($d = mysql_fetch_assoc($return)) {
?><option value="<?=$d['value']?>"<?
if ($other_table_value == $d['value'])
	echo " selected";
?>><?=$d['name']?></option>
<?
} 

Ok cool, I am assuming that this will be OK once I work out the parse
error on the above option.

> Third:
> If you're using MySQL, check this out: 
> http://www.mysql.com/doc/en/Fulltext_Search.html

> If you're using something else, it's more complex I think. Someone may

> have an
> elegant solution, but I would do something like:

// Get total number of keywords:
$numofkeywords = count(str_replace ( " ", " ", $keywords)); 

// Split up your search words:
$search = explode(" ", $keywords);
$total_matched = 0;
// loop through the array of search terms and get number of returns.
foreach ($search as $searchword) {
	$total_matched	 += count(str_replace($searchword, $searchword,
$keywords));
}
// echo out the result in percent. (to one decimal place even!) 
echo "Percent Matched: ".round(($total_matched/$numofkeywords)*100),
1)." %";


This only partly resolves my problem, I am not looking for a word count,
I am looking to return those records that have one or more of the
keywords in them, and display a percentage result next to each record
that matches.

-- 
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic