$strSearch = $_POST["mySearch"]; //txt รับค่ามา
include "../config_db.php";
$strSQL = "SELECT * FROM numproduct, lens, category WHERE numproduct.Lens_ID = lens.Lens_ID AND numproduct.Category_ID = category.Category_ID ";
$result = mysql_query($strSQL) or die ("Error Query [".$strSQL."]");
$rs = mysql_fetch_array($result);
if($rs['Lens_Name']!=1){// บรรทัดนี้ผ่านเงื่อนไข
$strSQL = "SELECT * FROM numproduct, lens, category WHERE numproduct.Lens_ID = lens.Lens_ID AND numproduct.Category_ID = category.Category_ID AND lens.Lens_Name LIKE '".$strSearch."%' ";
$result = mysql_query($strSQL) or die ("Error Query [".$strSQL."]");
}else{ //บรรทัดนี้ไม่ผ่านเงื่อนไข
$strSQL= "SELECT * FROM numproduct, lens, category WHERE numproduct.Lens_ID = lens.Lens_ID AND numproduct.Category_ID = category.Category_ID AND category.Category_NameSph LIKE '".$strSearch."%' ";
$result = mysql_query($strSQL) or die ("Error Query [".$strSQL."]");
}