我有以下的搜索引擎:使搜索查詢更強大
HTML代碼:
<form id="header-search" action="car-list.php" method="get">
<input type="text" name="search" value="<?php echo $_GET['search']; ?>" id="text" placeholder="Zoek hier.." class="quick-search" onchange >
<select name="type-option">
<option value="auto" selected="selected">Auto's</option>
<!-- <option value="bikes">Motoren</option>
<option value="trucks">Trucks</option>
<option value="Parts">Parts</option> -->
</select>
<div class="search-submit">
<input type="submit" name="submit" id="search" value="Zoeken"/>
<input type="hidden" name="page" id="text" value="1" class="quick-search" >
<input type="hidden" name="ipp" id="text" value="25" class="quick-search" >
</div>
</form>
PHP代碼:
<?php
$searchq = $_GET['search'];
$searchq = htmlspecialchars($searchq);
$searchq = mysql_real_escape_string($searchq);
$photo=mysql_query("SELECT * FROM `adver` WHERE merk LIKE '%$searchq%' OR titel
LIKE '%$searchq%' OR model LIKE '%$searchq%' ORDER BY car_id DESC $pages->limit")or die(mysql_error());
while($get_photo=mysql_fetch_array($photo)){
?>
<a href="<?php echo 'car-details.php?merk='.$get_photo['merk'] .'&car_id=' .$get_photo['car_id'] .'&titel=' .$get_photo['titel'] ;?>">
<img src="<?php echo $get_photo['path'] ; ?>" style="border:1px solid #021a40;" alt="<?php echo $get_photo['merk'] ;?>" }/>
我有一個表。有3列model, merk, titel
。我們說model = Audi
和merk = A6
。當我搜索「奧迪」或「A6」的結果時,我得到了結果,但是當我搜索奧迪A6時,我沒有收到任何結果。
所以我想要從相同的$Row
兩列的組合。我怎樣才能做到這一點?
老兄... sql注入。看看它。 –
另外XSS'」....>'如果用戶搜索'「>' – Jompper
謝謝,但是我使用 $ SEARCHQ = mysql_real_escape_string($ SEARCHQ); 難道這還不夠,以防止SQL注入 – user3052155