<?php
//get data
session_start();
$button = $_GET['submit'];
$search = $_GET['search'];
if (!$button)
echo "YOU DIDNT SUBMIT A KEYWORD";
else
{
if (strlen($search)<=2)
echo "SEARCH TERM TOO SHORT";
else
{
echo"You searched for <b>$search</b><hr size='1'>";
//connect to database
include("connect.php");
// a bit of filtering
$search = strtoupper($search);
$search= strip_tags($search);
$search = trim ($search);
$search_exploded = explode(" ",$search);
foreach ($search_exploded as $search_each)
{
//construct query
$x++;
if ($x==1)
$construct .= "CONCAT(role_category1, role_category2, role_category3, role_category4) LIKE '%$search_each%'";
else
$construct .= " OR CONCAT(role_category1, role_category2, role_category3, role_category4) LIKE '%$search_each%'";
}
//echo out construct
$construct = "SELECT * FROM jobdescription WHERE $construct";
$run = mysql_query($construct);
$foundnum = mysql_num_rows($run);
if ($foundnum==0)
echo "No results found.";
else
{
echo "$foundnum results found!<p>";
while ($runrows = mysql_fetch_assoc($run))
{
$jobdescriptionid = $runrows['jobdescriptionid'];
$companyid = $runrows['companyid'];
$companyid = $runrows['companyid'];
$role_1= $runrows['role_1'];
$role_location_1 = $runrows['role_location_1'];
$role_category_1 = $runrows['role_category_1'];
$role_term_1 = $runrows['role_term_1'];
$role_description_1 = $runrows['role_description_1'];
$role_2= $runrows['role_2'];
$role_location_2 = $runrows['role_location_2'];
$role_category_2 = $runrows['role_category_2'];
$role_term_2 = $runrows['role_term_2'];
$role_description_2 = $runrows['role_description_2'];
echo "
<b>$companyid
<b>$jobseekerfirstname $jobseekerlastname </b><br>
$role_1<br>
$role_location_1<br>
$role_category_1<br>
$role_2<br>
$role_location_2<br>
$role_category_2<br>";
}
}}}
?> am using the php script but its still now identifying what am searching for. Am trying to search for fields in the same table but different columns (heads of these columns are role_category1,role_category2.....) any suggestions