<?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>";
}
}}}
?>
PHP 스크립트를 사용하지만 검색중인 항목을 식별 할 수 있습니다. 같은 테이블의 필드하지만 서로 다른 열을 검색하려고 제안PHP를 사용하여 검색하십시오. 동일한 표의 키와 여러 열을 비교하는 것
글쎄, 네 질문은 뭐니? –