//**โดยที่ ราคาสินค้าเริ่มต้น มาจาก textbox หรือ select อะไรก็แล้วแต่ //** ราคาสินค้าเริ่มต้น มาจาก textbox หรือ select อะไรก็แล้วแต่ select * from ตารางสินค้า where ราคาสินค้า between '$ราคาสินค้าเริ่มต้น' and '$ราคาสินค้าเริ่มต้น';
SELECT * FROM tb_Product WHERE Price BETWEEN '1000000' AND '3000000';
<? //include("check_session.php"); include("config.inc.php"); $mat_type = array("ครุภัณฑ์สำนักงาน","ครุภัณฑ์คอมพิวเตอร์","ครุภัณฑ์โฆษณาและเผยแพร่","ครุภัณฑ์การศึกษา","ครุภัณฑ์อื่นๆ"); ?> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <title>ค้นหา</title> </head> <body> <form name="frmSearch" method="get" action="<?=$_SERVER['PHP_SELF']?>"> <table width="854" border="1"> <tr> <th width="844">ราคาห้องพัก <select name="go_price" id="go_price"> <option>- เลือกราคา -</option> <option value="1" <? if($price==1 ){?>selected<? }?>>น้อยกว่า1000</option> <option value="2" <? if($price==2 ){?>selected<? }?>>1001-1500</option> <option value="3" <? if($price==3 ){?>selected<? }?>>1501-2000</option> <option value="4" <? if($price==4 ){?>selected<? }?>>2001-2500</option> <option value="5" <? if($price==5 ){?>selected<? }?>>2501-3000</option> <option value="6" <? if($price==6 ){?>selected<? }?>>มากกว่า 3000</option> </select> -->ชื่อ - <select name="go_type" id="go_type" > <option></option> <? foreach ($mat_type as $key=>$val) { ?> <option value="<?=$val?>" <? if (!(strcmp( "$val", $_GET["go_type"]))) {echo "selected=\"selected\"";} ?>> <?=$val?> </option> <? } ?> </select> <label></label> <label></label> <input type="submit" value="Search"></th> </tr> </table> <p> </p> </form> <? $price = $_GET['go_price']; switch($price){ case 1: $where = " < 1000 "; break; case 2: $where = " BETWEEN 1001 AND 1500 "; break; case 3: $where = " BETWEEN 1501 AND 2000 "; break; case 4: $where = " BETWEEN 2001 AND 2500 "; break; case 5: $where = " BETWEEN 2501 AND 3000 "; break; case 6: $where = " > 3000 "; break; } if($_GET["go_price"] != "" || $_GET["go_type"] != "") { $strSQL = "SELECT * FROM goods_source WHERE 1"; if($_GET["go_price"] != "" ) { $strSQL .= " and go_price $where "; } if($_GET["go_type"] != "" ) { $strSQL .= " and go_type= '".$_GET["go_type"]."'"; } } $objQuery = mysql_query($strSQL) or die ("Error Query [".$strSQL."]"); ?> <table width="919" border="1"> <tr> <th width="126"> <div align="center">id_prd </div></th> <th width="147"> <div align="center">name_prd </div></th> <th width="138"> <div align="center">ref_id_type </div></th> <th width="136"> <div align="center">detail_prd </div></th> <th width="177"> <div align="center">price_prd </div></th> <th width="155"> <div align="center">photo_prd</div></th> </tr> <? while($objResult = mysql_fetch_array($objQuery)) { ?> <tr> <td><div align="center"><?=$objResult["go_num"];?></div></td> <td><?=$objResult["go_name"];?></td> <td><?=$objResult["go_type"];?></td> <td><div align="center"><?=$objResult["go_price"];?></div></td> .<td align="right"><?=$objResult["go_name_re"];?></td> <td align="right"><?=$objResult["go_store"];?></td> </tr> <? } ?> </table> <? //mysql_close(); ?> </body> </html>
เพื่อความปลอดภัยของเว็บบอร์ด ไม่อนุญาติให้แทรก แท็ก [img]....[/img] โดยการอัพโหลดไฟล์รูปจากที่อื่น เช่นเว็บไซต์ ฟรีอัพโหลดต่าง ๆ อัพโหลดแทรกรูปภาพ ให้ใช้บริการอัพโหลดไฟล์ของไทยครีเอท และตัดรูปภาพให้พอดีกับสกรีน เพื่อความโหลดเร็วและไฟล์ไม่ถูกลบทิ้ง