我有下面的代码,它运行良好。但是,我仅限于搜索两行。我想再搜索两行(共 4 行)。我已经尝试了几种技术,但我无法让它发挥作用。有时我会得到重复的结果。
<?php
$term = $_POST['term'];
$connect = new mysqli("localhost", "root", "hala3ammi", "phprealty");
$sql = "
SELECT phprealty_property.*, phprealty_prop_img.p_id, phprealty_prop_img.fn
FROM phprealty_property
INNER JOIN phprealty_prop_img
ON phprealty_property.id = phprealty_prop_img.p_id
WHERE phprealty_prop_img.def='1'
AND (phprealty_property.title like '%$term%'
OR phprealty_property.full_desc like '%$term%')";
$query = mysqli_query($connect, $sql) or die (mysqli_error());
$result = mysqli_query($connect, $sql);
$found = mysqli_num_rows($result);
echo '<br/> Search result(s): '.$found;
while ($row = mysqli_fetch_array($result)){
$img = $row["fn"];
$thumb = 'th_' . $img;
$duh = '<img src="../falcon/listImgs/' . $thumb . '" />';
echo '<br/> Title: '.$row['title'];
echo '<br/> Price: '.$row['price'];
echo '<br/> Type: '.$row['type'];
echo '<br/> Image: '.$duh;
echo '<br/> Full Desc: '.$row['full_desc'];
echo '<br/><br/>';
}
?>
数据库:
房地产
我要搜索的表:
phprealty_property
INNER 连接用于从下表中检索默认缩略图。
phprealty_prop_img
WHERE phprealty_prop_img.def='1'
先感谢您。