<meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <link href="main_style.css" rel="stylesheet" type="text/css"> <? include"connect.php"?> <? include"paging.php"?> <? //*** Delete Condition ***// if($_GET["Action"] == "Del") { $strSQL = "DELETE FROM class "; $strSQL .="WHERE class_id = '".$_GET["cID"]."' "; $objQuery = mysql_query($strSQL); if(!$objQuery) { echo "Error Delete [".mysql_error()."]"; } //header("location:$_SERVER[PHP_SELF]"); //exit(); } ?> <fieldset style="width:100%; background-color:#e7e7ff;"> <legend><b>รุ่นรถ</b></legend> <form name="frmSearch" method="get" action="<?=$_SERVER['SCRIPT_NAME'];?>"> <table style="font-family:Verdana, Geneva, sans-serif; font-size:13px;" > <tr> <th>รหัสรุ่นรถ <select name="txtKeyword2" id="txtKeyword2"> <option value="">--เลือก--</option> <? $strSQL = "SELECT * FROM brand ORDER BY brand_id ASC"; $objQuery = mysql_query($strSQL); while($objResuut = mysql_fetch_array($objQuery)) { ?> <option value="<?=$objResuut["brand_id"];?>" size="14"><?=$objResuut["brand_name"];?></option> <? } ?> </select> <input name="txtKeyword1" type="text" id="txtKeyword1" value="<?=$_GET["txtKeyword1"];?>"> <input type="submit" value="ค้นหา"></th> </tr> </table> </form> </fieldset> <? include"connect.php"; // Search By class_name,brand_id $strSQL = "SELECT * FROM class INNER JOIN brand ON brand.brand_id = class.brand_id WHERE (class_name LIKE '%".$_GET["txtKeyword1"]."%' AND class.brand_id LIKE '%".$_GET["txtKeyword2"]."%')"; $objQuery = mysql_query($strSQL) or die ("Error Query [".$strSQL."]"); $Num_Rows = mysql_num_rows($objQuery); $Page = (isset($_GET['Page']))? intval($_GET['Page']) : 1; $Per_Page = 13; // Per Page //$Page = $_GET["Page"]; $limit_start = ($Page-1)*$Per_Page; if(!$_GET["Page"]) { $Page=1; } $Prev_Page = $Page-1; $Next_Page = $Page+1; $Page_Start = (($Per_Page*$Page)-$Per_Page); if($Num_Rows<=$Per_Page) { $Num_Pages =1; } else if(($Num_Rows % $Per_Page)==0) { $Num_Pages =($Num_Rows/$Per_Page) ; } else { $Num_Pages =($Num_Rows/$Per_Page)+1; $Num_Pages = (int)$Num_Pages; } $strSQL .="order by class_no ASC LIMIT $Page_Start , $Per_Page"; $objQuery = mysql_query($strSQL); ?> <form name="frmMain" method="GET" action="<?=$_SERVER["PHP_SELF"];?>"> <input type="hidden" name="hdnCmd" value=""> <table style="font-family:Verdana, Geneva, sans-serif; font-size:13px;" width="100%"> <tr bgcolor="#000080" style="color:#FFF;"> <td width="64" height="26" align="left"><b>รหัสรุ่น</b></td> <td width="361" align="left"><b>ชื่อรุ่น</b></td> <td width="277" align="left"><b>ยี่ห้อ</b> </td> <td width="179" align="center"><b>ทำรายการ</b></td> </tr> <? while($objResult = mysql_fetch_array($objQuery)) { $i++; if($i%2==0) { $bg = "#cbd0ff"; } else { $bg = "#FFFFFF"; } ?> <? if($objResult["class_id"] == $_GET["cID"] and $_GET["Action"] == "Edit") { ?> <tr bgcolor="<?=$bg;?>"> <td align="left" height="26"><?=$objResult["class_no"];?></td> <td> <input type="hidden" name="class_id" size="3" value="<?=$objResult["class_id"];?>"> <input type="text" name="class_name" size="6" style="width:100px" onKeyPress="return english2(event,this.value)" onChange="javascript:this.value=this.value.toUpperCase();" value="<?=$objResult["class_name"];?>"> </td> <td><?=$objResult["brand_name"];?></td> <td align="center"> <input name="btnAdd" type="button" id="btnUpdate" value="บันทึก" OnClick="frmMain.hdnCmd.value='Update';frmMain.submit();"> <input name="btnAdd2" type="button" id="btnCancel" value="ยกเลิก" onclick="window.history.go(-1);" /> </td> </tr> <? }else{ ?> <tr bgcolor="<?=$bg;?>"> <td align="left" height="26"><?=$objResult["class_no"];?></td> <td><?=$objResult["class_name"];?></td> <td><?=$objResult["brand_name"];?></td> <td align="center"> <a href="<?=$_SERVER["PHP_SELF"]."?Page=$Page";?>&Action=Edit&cID=<?=$objResult["class_id"];?>"> <img src="image/edit.png" /></a> <a href="JavaScript:if(confirm('คุณต้องการลบข้อมูลใช่หรือไม่ ?')==true){window.location='<?=$_SERVER["PHP_SELF"];?> ?Action=Del&cID=<?=$objResult["class_id"];?>';}"> <img src="image/delete.png" /></a> </td> </tr> <? } //esle } //while ?> </table> </form> <br> <div align="center" style="font-family:Verdana, Geneva, sans-serif; font-size:13px;"> <b>รายการทั้งหมด <?= $Num_Rows;?> รายการ : <?=$Num_Pages;?> หน้า :</b> <? if($Prev_Page) { echo " <a href='$_SERVER[SCRIPT_NAME]?Page=$Prev_Page&txtKeyword1=$_GET[txtKeyword1]&txtKeyword2=$_GET[txtKeyword2]'><< Back</a> "; } for($i=1; $i<=$Num_Pages; $i++){ if($i != $Page) { echo "[ <a href='$_SERVER[SCRIPT_NAME]?Page=$i&txtKeyword1=$_GET[txtKeyword1]&txtKeyword2=$_GET[txtKeyword2]'>$i</a> ]"; } else { echo "<b> $i </b>"; } } if($Page!=$Num_Pages) { echo " <a href ='$_SERVER[SCRIPT_NAME]?Page=$Next_Page&txtKeyword1=$_GET[txtKeyword1]&txtKeyword2=$_GET[txtKeyword2]'>Next>></a> "; } ?> <? if($_GET["hdnCmd"] == "Update") { $strSQL = "UPDATE class SET "; $strSQL .="class_name = '".$_GET["class_name"]."' "; $strSQL .="WHERE class_id = '".$_GET["class_id"]."' "; $objQuery = mysql_query($strSQL) or die (mysql_error()); if(!$objQuery) { echo "<script>alert('บันทึกข้อมูลแล้ว');window.location='".$_SERVER['PHP_SELF']."?Page=$Page';</script>"; } //header("location:$_SERVER[PHP_SELF]"); //exit(); } ?> <? mysql_close(); ?>
เพื่อความปลอดภัยของเว็บบอร์ด ไม่อนุญาติให้แทรก แท็ก [img]....[/img] โดยการอัพโหลดไฟล์รูปจากที่อื่น เช่นเว็บไซต์ ฟรีอัพโหลดต่าง ๆ อัพโหลดแทรกรูปภาพ ให้ใช้บริการอัพโหลดไฟล์ของไทยครีเอท และตัดรูปภาพให้พอดีกับสกรีน เพื่อความโหลดเร็วและไฟล์ไม่ถูกลบทิ้ง