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>";
	?>


Link to comment
Share on other sites

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.

Link to comment
Share on other sites

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);
	  }

 

 

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.