<?php
if ($jod_rod !="") { || $furniture !="" || $tel !="" || $air !="" || $pad_lom !="" || $ubc !="" || $internet !="" || $swim !="" || $police !="" || $key_card !="" || $tv !="" || $yod_ren !="" || $sak_pa !="" || $vong_j||n_pid !="" || $fitnet !="" || $minimart !="")
$condition=" WHERE (jod_rod LIKE '$jod_rod') and (furniture LIKE '$furniture' or tel LIKE '$tel' or air LIKE '$air' or pad_lom LIKE '$pad_lom' or ubc LIKE '$ubc' or internet LIKE '$internet' or swim LIKE '$swim' or police LIKE '$police' or key_card LIKE '$key_card' or tv LIKE '$tv' or yod_ren LIKE '$yod_ren' or sak_pa LIKE '$sak_pa' or vong_jorn_pid LIKE '$vong_jorn_pid' or fitnet LIKE '$fitnet' or minimart LIKE '$minimart')";
}
else
{
$condition=" WHERE (furniture LIKE '$furniture') or (tel LIKE '$tel') or (air LIKE '$air') or (pad_lom LIKE '$pad_lom') or (ubc LIKE '$ubc') or (internet LIKE '$internet') or (swim LIKE '$swim') or (police LIKE '$police') or (key_card LIKE '$key_card') or (tv LIKE '$tv') or (yod_ren LIKE '$yod_ren') or (sak_pa LIKE '$sak_pa') or (vong_jorn_pid LIKE '$vong_jorn_pid') or (fitnet LIKE '$fitnet') or (minimart LIKE '$minimart')";
}
$sql = "SELECT * FROM ads". $condition;
?>
มาอีกครับท่าน คือผมได้สร้างตัวแปรไว้ดังนี้ น่ะครับ ถ้าเกิดว่าผมเลือกตัวแรก ด้วยเลยน่ะครับจะไม่มีปัญหาเลยครับแสดงผลได้ แต่ถ้าเกิดว่าผมไม้ได้เลือกตัวแรกด้วย จะทำให้ แสดง โค๊ด ===>SELECT * FROM ads where [font=Verdana]and[/font] air LIKE '1' ; ตัว and มันติดกับ where เลยอ่ะครับ ใครพอจะมีวิธี บ้างครับ ช่วยผมหน่อยครับ ควรจะใช้ and ไว้ตรงส่วนไหน เวลาที่มีการเลือกหลายๆ check box อ่ะคับ Code (PHP)
<?php
if($jod_rod ==1){$condition1=" jod_rod LIKE '$jod_rod'";}else{$condition1="";}
if($furniture ==1){$condition2=" and furniture LIKE '$furniture'";}else{$condition2="";}
if($tel ==1){$condition3=" and tel LIKE '$tel'";}else{$condition3="";}
if($air ==1){$condition4=" and air LIKE '$air'";}else{$condition4="";}
if($pad_lom ==1){$condition5=" and pad_lom LIKE '$pad_lom'";}else{$condition5="";}
if($ubc ==1){$condition6=" and ubc LIKE '$ubc'";}else{$condition6="";}
if($internet ==1){$condition7=" and internet LIKE '$internet'";}else{$condition7="";}
if($swim ==1){$condition8=" and swim LIKE '$swim'";}else{$condition8="";}
if($swim ==1){$condition8=" and swim LIKE '$swim'";}else{$condition8="";}
if($police ==1){$condition9=" and police LIKE '$police'";}else{$condition9="";}
if($key_card ==1){$condition10=" and key_card LIKE '$key_card'";}else{$condition10="";}
if($tv ==1){$condition11=" and tv LIKE '$tv'";}else{$condition11="";}
if($yod_ren ==1){$condition12=" and yod_ren LIKE '$yod_ren'";}else{$condition12="";}
if($sak_pa ==1){$condition13=" and sak_pa LIKE '$sak_pa'";}else{$condition13="";}
if($vong_jorn_pid ==1){$condition14=" and vong_jorn_pid LIKE '$vong_jorn_pid'";}else{$condition14="";}
if($fitnet ==1){$condition15=" and fitnet LIKE '$fitnet'";}else{$condition15="";}
if($minimart ==1){$condition16=" and minimart LIKE '$minimart'";}else{$condition16="";}
$condition="$condition1". "$condition2". "$condition3". "$condition4". "$condition5". "$condition6". "$condition7". "$condition8". "$condition9". "$condition10". "$condition11". "$condition12". "$condition13". "$condition14". "$condition15". "$condition16";
print $sql = "SELECT * FROM ads where ". $condition;
?>