Quantcast
Channel: iT邦幫忙
Viewing all articles
Browse latest Browse all 15645

PHP用下拉式選單後以中文關鍵字搜尋搜尋不到,但用數字改查編號就可以?如何避開中文字搜尋變亂碼而查不到的問題?

$
0
0
抱歉我原本用一般的文字bar來作中文關鍵字的查詢是可以查的到,但是改用下拉式選單後再用中文字查詢就查不到,若改用數字查詢ID就可以,想請問專業的大大們要如何才能避開中文字查詢亂碼的問題?
<?php
    header("Content-Type: text/html; charset=utf8_unicode_ci");
    include("connMysql.php");
    $seldb=@mysql_select_db("hmo");
    if (!$seldb) die ("資料庫連結失敗");
    mysql_query("SET NAMES 'utf8'");
if(isset($_GET["keyword"])&&($_GET["action"]="1")&&($_GET["keyword"]!="")){
    $sql_query = "SELECT * FROM `access` WHERE `cName` LIKE '%".$_GET["keyword"]."%'  " ;
}if(isset($_GET["keyword"])&&($_GET["action"]="18")&&($_GET["keyword"]!="")){
	$sql_query = "SELECT * FROM `access` WHERE `cID` LIKE '%".$_GET["keyword"]."%'  " ;
}else{
    $sql_query = "SELECT * FROM `access` ORDER BY `cID` DESC";
}
function keepURL(){
    $keepURL = "";
    if(isset($_GET["keyword"])) $keepURL.="&keyword=".urlencode($_GET["keyword"]);

    return $keepURL;
}
?><meta http-equiv="Content-Type" content="text/html; charset=utf-8"/><title>會員查詢系統</title><form name="form1" method="GET" action="hmo-2.php" ><input name="keyword" type="hidden" value="keyword"><select name="action" id="action" ><option value="1">姓名</option><option value="18">編號</option></select>

Viewing all articles
Browse latest Browse all 15645

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>