Jump to content

[SOLVED] Need Serious PHP/MYSQL Full-Text Search Help!!


virtuexru

Recommended Posts

Ok. I have this search setup so far, to search using a Full-Text index. Now I'm having some problems. I can't find keywords with things like "C#" or "C++" or "Java" (Java maybe too short?) but am OK when searching for "Windows" or "Engineer".

 

Thats my first question. Second main question is, How do I create filters? Such as filtering one row like "City"?

 

Here's my code so far:

 


	<?php
	$keyword = $_POST['keyword'];

			$results = "
				SELECT *,
					MATCH(title, description, location, category) AGAINST('$keyword') AS score
					FROM joborder
				WHERE MATCH(title, description, location, category) AGAINST('$keyword')
				ORDER BY score DESC";
			$rest = mysql_query($results);
	?>

	<table width="100%" border="0" cellspacing="0" cellpadding="2">		
	<?php

	if (!$rest)
		{ echo mysql_error(); }
			while($row = mysql_fetch_array($rest)) {
				$url = 'http://www.website.com/viewlog.php?id='.$row['number'].'';
				$html = '<a href="'.$url.'">'.$row['title'].'</a>';

				echo "<tr bgcolor=\"#99CCFF\"><td><b>{$html}</b></td>";
				echo "<td>{$row['location']}</td></tr>";
				echo "<tr bgcolor=\"#CCCCCC\"><td>{$row['description']}</td>";
				echo "<td>{$row['salary']}<br/></td></tr>";
				echo "<tr><td> </td><td> </td></tr>";
			}
			echo "</table>";
	?>


Like say, I have columns for "Category". How would I create say, like check boxes for 4 categories:

 

Blue

Red

Yellow

Green

 

The user wants to search keyword

 

"car"

 

only in the

 

"Green"

 

category..

 

How would I go about implementing this?

SELECT
*,MATCH(title, description, location, category) AGAINST('$keyword') AS score
FROM
joborder
WHERE
category = 'Green'
AND
MATCH(title, description, location, category) AGAINST('$keyword')
ORDER BY
score DESC";

 

If you're looking for help with the PHP code for this you should post in the PHP_Help forum.

Wow thank you Shoz!

 

That worked perfectly. I just do a quick

 

if(!$variable)

 

statement to see whether or not checkboxes have been filled in or what not.

 

Here's the new code:

 

// $catin = checkbox variable input

 

	$keyword = $_POST['keyword'];
	$catin = $_POST['catin'];

	if(!$catin)
	  {
		$results = "
			SELECT *,
				MATCH(title, description, location, category) AGAINST('$keyword') AS score
				FROM joborder
				WHERE MATCH(title, description, location, category) AGAINST('$keyword')
			ORDER BY score DESC";
		$rest = mysql_query($results);
	  }
     else
	  {		
		$results = "
			SELECT *,
				MATCH(title, description, location, category) AGAINST('$keyword') AS score
				FROM joborder
				WHERE category = '$catin' AND MATCH(title, description, location, category) AGAINST('$keyword')
			ORDER BY score DESC";
		$rest = mysql_query($results);
	  }

 

 

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.