Ben bir alanda kullanıcı girişi kullanarak veri search ing yapmak istiyorum. Kullanıcı "D+t+y+g,k,j,h" harfler "d and t and y and g or k or j or h" olan değerleri aramak istiyorsanız girerse budur. Ben PHP str_replace
fonksiyonu çalıştı, ancak sonuç gibi değildi.
//kw is text field...
if($kw != "") {
//here we check for some data in field; if yes, continue below
//c is for ',' replaced in JavaScript
$kw1 = str_replace("c"," OR bcm.keywords LIKE '$kw%' ",$kw);
//p is for '+' replaced in JavaScript//'bcm' is table name.
$kw3 = str_replace("p"," AND bcm.keywords LIKE '$kw%' ",$kw1);
//for appending into main query string
$app.=$kw3;
//$app.=" AND bcm.keywords LIKE '$kw%'";
}
... Ama girişi için "D+t+y+g,k,j,h" sorgu böyle çıkıyor:
AND bcm.keywords LIKE 'Dptpypgckcjch%' t
AND bcm.keywords LIKE 'Dptpypgckcjch%' y
AND bcm.keywords LIKE 'Dptpypgckcjch%' g
OR bcm.keywords LIKE 'D
AND bcm.keywords LIKE 'Dptpypgckcjch%' t
AND bcm.keywords LIKE 'Dptpypgckcjch%' y
AND bcm.keywords LIKE 'Dptpypgckcjch%' gckcjch%' k
OR bcm.keywords LIKE 'D
AND bcm.keywords LIKE 'Dptpypgckcjch%' t
AND bcm.keywords LIKE 'Dptpypgckcjch%' y
AND bcm.keywords LIKE 'Dptpypgckcjch%' gckcjch%' j
OR bcm.keywords LIKE 'D
AND bcm.keywords LIKE 'Dptpypgckcjch%' t
AND bcm.keywords LIKE 'Dptpypgckcjch%' y
AND bcm.keywords LIKE 'Dptpypgckcjch%' gckcjch%' h**
... Ne / ihtiyaç istiyorum olduğunda:
AND bcm.keywords LIKE 'D%'
AND bcm.keywords LIKE 't%'
AND bcm.keywords LIKE 'y%'
AND bcm.keywords LIKE 'g%'
OR bcm.keywords LIKE 'k%'
OR bcm.keywords LIKE 'j%'
OR bcm.keywords LIKE 'h%'