RE: populating <select> and searching to criteria

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 




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


[Index of Archives]     [PHP Home]     [PHP Users]     [Postgresql Discussion]     [Kernel Newbies]     [Postgresql]     [Yosemite News]

  Powered by Linux