<? isset($_POST["txtType"]) ? $test = $_POST["txtType"] : $test = ''; isset($_POST["txtbrand"]) ? $Ink = $_POST["txtbrand"] : $test = ''; ?> <form name="frmSearch" method="post" action="<?=$_SERVER['SCRIPT_NAME'];?>" onSubmit="JavaScript:return fncSubmit();"> ประเภทสินค้า <select name="txtType" id="txtType"> <option value="">--</option> <option value="Printer" <? if($test == "Printer"){echo"selected";}?>>Printer</option> <option value="Ink" <? if($test == "Ink"){echo"selected";}?>>Ink</option> </select> ยี่ห้อ <select name="txtbrand" id="txtbrand"> <option value="">--</option> <option value="Brother" <? if($Ink == "Brother"){echo"selected";}?>> Brother </option> <option value="Canon" <? if($Ink == "Canon"){echo"selected";}?>> Canon </option> <option value="Epson" <? if($Ink == "Epson"){echo"selected";}?>> Epson </option> <option value="HP" <? if($Ink == "HP"){echo"selected";}?>> HP </option> </select> <input type="submit" class="button" value="ตกลง"> </form> <? $objConnect = mysql_connect("localhost","root","2598083") or die("Error Connect to Database"); $objDB = mysql_select_db("mydatabase1"); mysql_query("SET names UTF8"); $strSQL = "select * from tb_product WHERE Pd_Type "; if($test != "" and $Ink != "") { $strSQL .= " = '".$test."' AND Pd_Name LIKE '%".$Ink."%' "; } $objQuery = mysql_query($strSQL) or die ("Error Query [".$strSQL."]"); ?> <? echo $test , $Ink;?> <table width="1020" height="92" border="1" cellpadding="1" cellspacing="0"> <tr> <td height="29" colspan="2" align="center"><strong>ชื่อสินค้า</strong></td> <td align="center"><strong>รายละเอียดสินค้า</strong></td> <td align="center"><strong>ราคา (บาท)</strong></td> <td width="49" align="center"><strong>ประกัน</strong></td> </tr> <? while($objResult = mysql_fetch_array($objQuery)) { ?> <tr> <td width="28" height="32"><a href="../img/product/<?php echo $objResult['Pd_Picture']; ?>" rel="lightbox"><img src="../img/product/<?php echo $objResult['Pd_Picture']; ?>" border="0" width="28" height="28" /></a></td> <td width="276"><strong><?php echo $objResult["Pd_Name"]; ?> <?php if($objResult['Pd_Status'] == 'ไม่ขายแล้ว') { echo "<font color=\"#FF0000\">ไม่ขายแล้ว</font> "; } ?> </strong></td> <td width="546"><strong><?php echo $objResult['Pd_Description']; ?></strong></td> <td width="99" colspan="-6" align="center"><strong>350</strong></td> <td width="49" align="center" style="color: #F00;"><strong>3Y</strong></td> </tr> <?php } ?> </table>
$strSQL = 'select * from tb_product WHERE 1 '. ($test ? " and Pd_Type = '$test' " : '').' .( $Ink ? "' and Pd_Name LIKE '%$Ink%' ");
$where = $test ? " Pd_Type = '$test' " : ''; $where .= $Ink ? ($where? ' or ' : '') . " Pd_Name LIKE '%$Ink%' " : ''); $strSQL = 'select * from tb_product WHERE 1 '.($where ? ' and (' . $where . ')': '') ;
$where = $test ? " Pd_Type = '$test' " : ''; $where .= $Ink ? ($where? ' and ' : '') . " Pd_Name LIKE '%$Ink%' " : ''); $strSQL = 'select * from tb_product WHERE 0 '. $where ? ' or (' . $where . ')': '') ;
$strSQL = 'select * from tb_product WHERE 0 '.($test ? " or Pd_Type = '$test' " : '').' .( $Ink ? "' or Pd_Name LIKE '%$Ink%' ");
เพื่อความปลอดภัยของเว็บบอร์ด ไม่อนุญาติให้แทรก แท็ก [img]....[/img] โดยการอัพโหลดไฟล์รูปจากที่อื่น เช่นเว็บไซต์ ฟรีอัพโหลดต่าง ๆ อัพโหลดแทรกรูปภาพ ให้ใช้บริการอัพโหลดไฟล์ของไทยครีเอท และตัดรูปภาพให้พอดีกับสกรีน เพื่อความโหลดเร็วและไฟล์ไม่ถูกลบทิ้ง