0
function comp_post_code($comp_post_code){
global $host, $dbname, $user, $pass;
$DBH = new PDO("mysql:host=$host;dbname=$dbname", $user, $pass);
$DBH->setAttribute(PDO::ATTR_ERRMODE,PDO::ERRMODE_EXCEPTION); ///*** for error handling
$STH = $DBH->prepare("SELECT * from uk_data where
comp_post_code like :comp_post_code and cat1 like :cat");
$STH->bindValue(':cat', "%$cat1%", PDO::PARAM_STR);
$STH->bindValue(':comp_post_code', "%$comp_post_code%", PDO::PARAM_STR);
$STH->execute();
$STH->setFetchMode(PDO::FETCH_ASSOC);
return $STH;
}
選擇多條記錄,我有CAT1到cat10 ..我想獲得的數據輸出,而無需編寫像短查詢
and comp_post_code like :comp_post_code and cat2 like :cat
and comp_post_code like :comp_post_code and cat3 like :cat
我有出路,這個長碼......我們可以翁寫代碼並退出,但仍然想知道我們可以用其他方式做什麼?
表結構
你可以張貼表結構? (cat1 cat10是表格欄?) – FlorinelChis
@FlorinelChis是你是,我有編輯問題... – Harinder
:貓應該在* all * cat [1-n]或任何*列中找到? – FlorinelChis