<?php
require_once('../lankain.php');
if(isset($_POST['queryString'])) {
$queryString = $dbc->real_escape_string($_POST['queryString']);
if(strlen($queryString) >0) {
//$query = $dbc->query("SELECT subjects FROM subject WHERE subjects LIKE '$queryString%' LIMIT 10");
$q = "SELECT keyword, col
FROM (
SELECT tutor_name AS keyword, 'Tutors' col FROM tutors
UNION
SELECT subjects AS keyword, 'Subject' col FROM subject
UNION
SELECT city_name AS keyword, 'City' col FROM city
UNION
SELECT institute_name AS keyword, 'Institute' col FROM institutes
) s
WHERE keyword LIKE '%$queryString%'
LIMIT 10";
$r = mysqli_query ( $dbc, $q);
if($q) {
while ($row = mysqli_fetch_array($r, MYSQL_ASSOC)) {
$col = $row['col'];
}
} else {
echo 'ERROR: There was a problem with the query.';
}
} else {
}
} else {
echo 'There should be no direct access to this script!';
}
?>
私のクエリは、カテゴリ名を選択せずに、科目、チューター名、機関、および都市のみを選択します。ここで、結果セットに従ってカテゴリ名を追加する必要があります..
phpでできることを知ることができますか?