$strSQL = " SELECT name, price FROM table1"; $strSQL .= " LEFT JOIN table2 ON table1.id = table2.id";
$strSQL = "SELECT * FROM tb_product "; $strSQL .= " LEFT JOIN tb_type ON tb_product .ref_id_type = tb_type.id_type"; $objQuery = mysql_query($strSQL) or die ("Error Query [".$strSQL."]"); ?> <table width="668" border="1"> <tr> <th width="83"> <div align="center">รหัสหอพัก</div></th> <th width="88"> <div align="center">ชื่อหอพัก </div></th> <th width="130"> <div align="center">ประเภทหอพัก </div></th> <th width="73"> <div align="center">ราคา</div></th> <th width="100"> <div align="center">รูปภาพ </div></th> <th width="154"> <div align="center">รายละเอียด</div></th> </tr> <? while($objResult = mysql_fetch_array($objQuery)) { ?> <tr> <td height="50"><div align="center"><?=$objResult["id_prd"];?></div></td> <td><div align="center"> <?=$objResult["name_prd"];?> </div></td> <td><div align="center"> <?=$objResult["ref_id_type"];?> </div></td> <td><div align="center"> <?=$objResult["price_prd"];?> </div></td> .<td align="right"><div align="center"> <?=$objResult["photo_prd"]; if ($photo_prd=="") { $photo_prd="temp.jpg"; }?>
<? $strSQL = "SELECT * FROM tb_product "; $strSQL .= " INNER JOIN tb_type ON tb_product .ref_id_type = tb_type.id_type"; $objQuery = mysql_query($strSQL) or die ("Error Query [".$strSQL."]"); ?> <table width="668" border="1"> <tr> <th width="83"> <div align="center">รหัสหอพัก</div></th> <th width="88"> <div align="center">ชื่อหอพัก </div></th> <th width="130"> <div align="center">ประเภทหอพัก </div></th> <th width="73"> <div align="center">ราคา</div></th> <th width="100"> <div align="center">รูปภาพ </div></th> <th width="154"> <div align="center">รายละเอียด</div></th> </tr> <? while($objResult = mysql_fetch_array($objQuery)) { ?> <tr> <td height="50"><div align="center"><?=$objResult["id_prd"];?></div></td> <td><div align="center"> <?=$objResult["name_prd"];?> </div></td> <td><div align="center"> <?=$objResult["name_type"];?> </div></td> <td><div align="center"> <?=$objResult["price_prd"];?> </div></td> .<td align="right"><div align="center"> <?=$objResult["photo_prd"]; if ($photo_prd=="") { $photo_prd="temp.jpg"; }?>
<html> <head> <title>ค้นหา</title> </head> <body> <form name="frmSearch" method="post" action="<?=$_SERVER['PHP_SELF']?>"> <table width="790" border="1"> <tr> <th width="780">ราคาห้องพัก <select name="price" id="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> ค้นหา <input name="txtKeyword" type="text" id="txtKeyword" value="<?=$_POST["txtKeyword"];?>"> <input type="submit" value="Search"></th> </tr> </table> </form> <? @include("connect.php"); ?> <? if($_REQUEST['price']!=''){ $price = $_REQUEST['price']; switch($price){ case 1: $where = " WHERE price_prd < 1000 "; break; case 2: $where = " WHERE price_prd BETWEEN 1001 AND 1500 "; break; case 3: $where = " WHERE price_prd BETWEEN 1501 AND 2000 "; break; case 4: $where = " WHERE price_prd BETWEEN 2001 AND 2500 "; break; case 5: $where = " WHERE price_prd BETWEEN 2501 AND 3000 "; break; case 6: $where = " WHERE price_prd > 3000 "; break; } } if($_REQUEST["txtKeyword"] != ""){ $detail = $_REQUEST["txtKeyword"]; $where = " WHERE (name_prd LIKE '%".$detail."%') "; } if($_REQUEST['price']!='' && $_REQUEST["txtKeyword"] != ""){ $price = $_REQUEST['price']; $name_prd = $_REQUEST["txtKeyword"]; switch($price){ case 1: $where = " WHERE price_prd < 1000 OR name_prd LIKE '%".$name_prd."%' "; break; case 2: $where = " WHERE price_prd BETWEEN 1001 AND 1500 OR name_prd LIKE '%".$name_prd."%'"; break; case 3: $where = " WHERE price_prd BETWEEN 1501 AND 2000 OR name_prd LIKE '%".$name_prd."%'"; break; case 4: $where = " WHERE price_prd BETWEEN 2001 AND 2500 OR name_prd LIKE '%".$name_prd."%'"; break; case 5: $where = " WHERE price_prd BETWEEN 2501 AND 3000 OR name_prd LIKE '%".$name_prd."%'"; break; case 6: $where = " WHERE price_prd > 3000 OR name_prd LIKE '%".$name_prd."%'"; break; } } $strSQL = "SELECT * FROM tb_product $where "; $strSQL .= " INNER JOIN tb_type ON tb_product.ref_id_type = tb_type.id_type"; $objQuery = mysql_query($strSQL) or die ("Error Query [".$strSQL."]"); ?> <table width="926" border="1"> <tr> <th width="110"> <div align="center">รหัสหอพัก</div></th> <th width="215"> <div align="center">ชื่อหอพัก </div></th> <th width="94"> <div align="center">ประเภทหอพัก </div></th> <th width="119"> <div align="center">ราคา</div></th> <th width="137"> <div align="center">รูปภาพ</div></th> <th width="211"> <div align="center">รายละเอียด</div></th> </tr> <? while($objResult = mysql_fetch_array($objQuery)) { ?> <tr> <td><div align="center"><?=$objResult["id_prd"];?></div></td> <td><div align="center"> <?=$objResult["name_prd"];?> </div></td> <td><div align="center"> <?=$objResult["name_type"];?> </div></td> <td><div align="center"> <?=$objResult["price_prd"];?> </div> </div></td> <td align="right"><div align="center"><?=$objResult["photo_prd"]; if ($photo_prd=="") { $photo_prd="temp.jpg"; }?> </div> </td> <td align="right"><div align="center"> [ <A HREF='search_view.php?id_prd=<?=$objResult["id_prd"];?>'>แสดงรายละเอียด </A>] </div> </td> </tr> <? } ?> </table> <? //mysql_close($objConnect); ?> </body> </html>
$strSQL .= " INNER JOIN tb_type ON tb_product.ref_id_type = tb_type.id_type";
<html> <head> <title>ค้นหา</title> </head> <body> <form name="frmSearch" method="post" action="<?=$_SERVER['PHP_SELF']?>"> <table width="641" border="1"> <tr> <th width="631">ราคาห้องพัก <select name="price" id="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> ค้นหา <input name="txtKeyword" type="text" id="txtKeyword" value="<?=$_POST["txtKeyword"];?>"> <input type="submit" value="Search"></th> </tr> </table> </form> <? @include("connect.php"); ?> <? if($_REQUEST['price']!=''){ $price = $_REQUEST['price']; switch($price){ case 1: $where = " WHERE price_prd < 1000 "; break; case 2: $where = " WHERE price_prd BETWEEN 1001 AND 1500 "; break; case 3: $where = " WHERE price_prd BETWEEN 1501 AND 2000 "; break; case 4: $where = " WHERE price_prd BETWEEN 2001 AND 2500 "; break; case 5: $where = " WHERE price_prd BETWEEN 2501 AND 3000 "; break; case 6: $where = " WHERE price_prd > 3000 "; break; } } if($_REQUEST["txtKeyword"] != ""){ $detail = $_REQUEST["txtKeyword"]; $where = " WHERE (name_prd LIKE '%".$detail."%') "; } if($_REQUEST['price']!='' && $_REQUEST["txtKeyword"] != ""){ $price = $_REQUEST['price']; $name_prd = $_REQUEST["txtKeyword"]; switch($price){ case 1: $where = " WHERE price_prd < 1000 OR name_prd LIKE '%".$name_prd."%' "; break; case 2: $where = " WHERE price_prd BETWEEN 1001 AND 1500 OR name_prd LIKE '%".$name_prd."%'"; break; case 3: $where = " WHERE price_prd BETWEEN 1501 AND 2000 OR name_prd LIKE '%".$name_prd."%'"; break; case 4: $where = " WHERE price_prd BETWEEN 2001 AND 2500 OR name_prd LIKE '%".$name_prd."%'"; break; case 5: $where = " WHERE price_prd BETWEEN 2501 AND 3000 OR name_prd LIKE '%".$name_prd."%'"; break; case 6: $where = " WHERE price_prd > 3000 OR name_prd LIKE '%".$name_prd."%'"; break; } } $strSQL = "SELECT * FROM tb_product "; $strSQL .= " INNER JOIN tb_type ON tb_product .ref_id_type = tb_type.id_type"; $objQuery = mysql_query($strSQL) or die ("Error Query [".$strSQL."]"); ?> <table border="1"> <tr> <th width="92"> <div align="center">รหัสหอพัก</div></th> <th width="97"> <div align="center">ชื่อหอพัก </div></th> <th width="140"> <div align="center">ประเภทหอพัก </div></th> <th width="83"> <div align="center">ราคา</div></th> <th width="110"> <div align="center">รูปภาพ </div></th> <th width="170"> <div align="center">รายละเอียด</div></th> </tr> <? while($objResult = mysql_fetch_array($objQuery)) { ?> <tr> <td height="50"><div align="center"><?=$objResult["id_prd"];?></div></td> <td><div align="center"> <?=$objResult["name_prd"];?> </div></td> <td><div align="center"> <?=$objResult["name_type"];?> </div></td> <td><div align="center"> <?=$objResult["price_prd"];?> </div></td> <td align="right"><div align="center"> <div align="center"> <?=$objResult["photo_prd"]; if ($photo_prd=="") { $photo_prd="temp.jpg"; }?> </div></td> <td>[ <A HREF='search_view.php?id_prd=<?=$objResult["id_prd"];?>'>แสดงรายละเอียด </A>] </div></td> </tr> <? } ?> </table> <? //mysql_close($objConnect); ?> </body> </html>
เพื่อความปลอดภัยของเว็บบอร์ด ไม่อนุญาติให้แทรก แท็ก [img]....[/img] โดยการอัพโหลดไฟล์รูปจากที่อื่น เช่นเว็บไซต์ ฟรีอัพโหลดต่าง ๆ อัพโหลดแทรกรูปภาพ ให้ใช้บริการอัพโหลดไฟล์ของไทยครีเอท และตัดรูปภาพให้พอดีกับสกรีน เพื่อความโหลดเร็วและไฟล์ไม่ถูกลบทิ้ง