是不是你數(shù)據(jù)庫(kù)那個(gè)字段給設(shè)置成了int型了(這種情況基本沒有可能,因?yàn)槿绻皇莍nt型它會(huì)報(bào)錯(cuò))?或者是你在向數(shù)據(jù)庫(kù)插入的時(shí)候,將a,b,c轉(zhuǎn)換成了int型?最好把你的程序代碼貼出來,也好幫你找錯(cuò)誤。
創(chuàng)新互聯(lián)主要從事網(wǎng)站設(shè)計(jì)、成都網(wǎng)站設(shè)計(jì)、網(wǎng)頁(yè)設(shè)計(jì)、企業(yè)做網(wǎng)站、公司建網(wǎng)站等業(yè)務(wù)。立足成都服務(wù)商水,10年網(wǎng)站建設(shè)經(jīng)驗(yàn),價(jià)格優(yōu)惠、服務(wù)專業(yè),歡迎來電咨詢建站服務(wù):18982081108
?php
include('Common/db.php'); //數(shù)據(jù)庫(kù)連接類
$db=new DB();
$shouzimu=strtoupper("r"); //傳過來的參數(shù)
$arr=$db-get_all("SELECT * FROM [user]");
foreach($arr as $rs){
$panduan=ff_letter_first($rs['uname']);//調(diào)用下面的方法
if($panduan==$shouzimu){
print_r($rs);
}
}
//生成字母前綴
function ff_letter_first($s0){
$firstchar_ord=ord(strtoupper($s0{0}));
if (($firstchar_ord=65 and $firstchar_ord=91)or($firstchar_ord=48 and $firstchar_ord=57)) return $s0{0};
$s=iconv("UTF-8","gb2312", $s0);
$asc=ord($s{0})*256+ord($s{1})-65536;
if($asc=-20319 and $asc=-20284)return "A";
if($asc=-20283 and $asc=-19776)return "B";
if($asc=-19775 and $asc=-19219)return "C";
if($asc=-19218 and $asc=-18711)return "D";
if($asc=-18710 and $asc=-18527)return "E";
if($asc=-18526 and $asc=-18240)return "F";
if($asc=-18239 and $asc=-17923)return "G";
if($asc=-17922 and $asc=-17418)return "H";
if($asc=-17417 and $asc=-16475)return "J";
if($asc=-16474 and $asc=-16213)return "K";
if($asc=-16212 and $asc=-15641)return "L";
if($asc=-15640 and $asc=-15166)return "M";
if($asc=-15165 and $asc=-14923)return "N";
if($asc=-14922 and $asc=-14915)return "O";
if($asc=-14914 and $asc=-14631)return "P";
if($asc=-14630 and $asc=-14150)return "Q";
if($asc=-14149 and $asc=-14091)return "R";
if($asc=-14090 and $asc=-13319)return "S";
if($asc=-13318 and $asc=-12839)return "T";
if($asc=-12838 and $asc=-12557)return "W";
if($asc=-12556 and $asc=-11848)return "X";
if($asc=-11847 and $asc=-11056)return "Y";
if($asc=-11055 and $asc=-10247)return "Z";
return 0;//null
}
?
下面是一段測(cè)試代碼,供參考。
script language="javascript"
function testFun(){
var inputStr = document.getElementById('inputStr').value;
var reg = /^[a-zA-Z0-9_\u4e00-\u9fa5]{6}$/
if(!reg.test(inputStr)){
alert("只能輸入漢字或者字母或者數(shù)字,長(zhǎng)度不能超過6位!");
} else {
alert("輸入正確");
}
}
/script
input type="text" id="inputStr" name="inputStr"
input type="button" onclick="testFun();" value="確定"
如果想匹配雙字節(jié)字符(包括漢字在內(nèi)):就用[^\x00-\xff]這個(gè)。為空校驗(yàn)?zāi)憔妥约簩懓伞?/p>
?php
//驗(yàn)證字符串
$str="編程";
//用正則匹配判斷
if(preg_match('/^[0-9a-zA-Z_\x{4e00}-\x{9fa5}]+$/u',$str)){
echo '符合驗(yàn)證規(guī)則??!';
}else{
echo '不符合驗(yàn)證規(guī)則!!';
}
?