使用此代码.. 我需要将 $code 变量添加到 sql 查询的 where 子句中。
if ( isset( $_POST['code_search_submitted'])) {
if ( isset( $_POST['searchCode']) && !empty( $_POST['searchText'])) {
$searchCode = $_POST['searchCode'];
$searchText = $_POST['searchText'];
echo $searchCode;
echo '<br />';
echo $searchText;
//if (is_numeric( $searchText ) && (strlen($searchText) == 4)) {
$numbers = explode(",", $searchText);
foreach($numbers as $number) {
$numbers = trim($number);
if (ctype_digit($numbers) && (strlen($numbers) == 4)) {
$code = $numbers ;
} else {
echo 'Can not cantain string and more than 4 digists number';
}
}
}
}
这是我的查询...
SELECT
tcs.tutor_id AS tid,
t.qualification,
GROUP_CONCAT( DISTINCT o.option_name SEPARATOR ', ') AS tutor_option,
timg.image_name AS img,
city_name AS city,
d.district_name AS district
FROM tutor_category_subject as tcs
INNER JOIN subject AS s ON tcs.subject_id = s.subject_id
INNER JOIN tutors AS t ON tcs.tutor_id = t.tutor_id
INNER JOIN address ON address.address_id = t.address_id
INNER JOIN city ON city.city_id = address.city_id
INNER JOIN district AS d ON d.district_id = city.district_id
LEFT JOIN tutor_images AS timg ON timg.tutor_id = tcs.tutor_id AND timg.image_type = 'profile'
WHERE t.tutor_code = ------------
GROUP BY tcs.tutor_id;
$code 变量有更多的成员代码,例如 2434,2345,5345,2354 等...谁能告诉我如何在 where 子句中使用它?
谢谢...