<? include('../config/connectdb.php'); if ($_POST["hdnCmd"] == 'Update') { $strSQL2 = "update member set "; $strSQL2 .="Name = '".$_POST["ttName"]."' "; $strSQL2 .=", Address = '".$_POST["ttAddress"]."' "; $strSQL2 .=", Country = '".$_POST["ttCountry"]."' "; $strSQL2 .=" where ID = ".$_POST["hddID"].""; $objQuery2 = mysql_query($strSQL2); if(!$objQuery2) { echo "Error Save [".mysql_error()."]"; } else { } } $strSQL = "SELECT * from member "; $objQuery = mysql_query($strSQL) or die ("Error Query [".$strSQL."]"); ?> <form name="frmMain" method="post" action="<?=$_SERVER["REQUEST_URI"];?>"> <input type="hidden" name="hdnCmd" value=""> <table width="800" border="0" align="center" cellpadding="3" cellspacing="1"> <tr> <td> </td> <td><strong>Date</strong></td> <td><strong>Name</strong></td> <td><strong>Address</strong></td> <td><strong>Country</strong></td> </tr> <? while($objResult = mysql_fetch_array($objQuery)) { ?> <tr> <td align="center"><input name="hddID" type="hidden" value="<?=$objResult["ID"];?>" /><label> <input type="submit" name="button" id="button" value="Save" OnClick="frmMain.hdnCmd.value='Update';frmMain.submit();"> </label></td> <td><?=$objResult["Dates"];?></td> <td><input name="ttName" type="text" value="<?=$objResult["Name"];?>" /></td> <td><input name="ttAddress" type="text" value="<?=$objResult["Address"];?>" /></td> <td><input name="ttCountry" type="text" value="<?=$objResult["Country"];?>" /></td> </tr> <? } ?> </table> </form> <? mysql_close(); ?>
<? include('../config/connectdb.php'); if ($_POST["hdnCmd"] == 'Update') { for($i=0; $i<count($_POST["hddID"]); $i++){ $strSQL2 = "update member set "; $strSQL2 .="Name = '".$_POST["ttName"][$i]."' "; $strSQL2 .=", Address = '".$_POST["ttAddress"][$i]."' "; $strSQL2 .=", Country = '".$_POST["ttCountry"][$i]."' "; $strSQL2 .=" where ID = ".$_POST["hddID"][$i].""; $objQuery2 = mysql_query($strSQL2) or die(mysql_error()); } } $strSQL = "SELECT * from member "; $objQuery = mysql_query($strSQL) or die ("Error Query [".$strSQL."]"); ?> <form name="frmMain" method="post" action="<?=$_SERVER["REQUEST_URI"];?>"> <input type="hidden" name="hdnCmd" value=""> <table width="800" border="0" align="center" cellpadding="3" cellspacing="1"> <tr> <td> </td> <td><strong>Date</strong></td> <td><strong>Name</strong></td> <td><strong>Address</strong></td> <td><strong>Country</strong></td> </tr> <? while($objResult = mysql_fetch_array($objQuery)) { ?> <tr> <td align="center"><input name="hddID[]" type="hidden" value="<?=$objResult["ID"];?>" /><label> <input type="submit" name="button" id="button" value="Save" OnClick="frmMain.hdnCmd.value='Update';frmMain.submit();"> </label></td> <td><?=$objResult["Dates"];?></td> <td><input name="ttName[]" type="text" value="<?=$objResult["Name"];?>" /></td> <td><input name="ttAddress[]" type="text" value="<?=$objResult["Address"];?>" /></td> <td><input name="ttCountry[]" type="text" value="<?=$objResult["Country"];?>" /></td> </tr> <? } ?> </table> </form> <? mysql_close(); ?>
$objQuery2 = mysql_query($strSQL2); echo $strSQL2;
<? include('../config/connectdb.php'); if ($_POST["hdnCmd"] == 'Update') { $selectedUpdate = $_POST["hddID"]; $strSQL2 = "update member set "; $strSQL2 .="Name = '".$_POST["ttName"][$selectedUpdate]."' "; $strSQL2 .=", Address = '".$_POST["ttAddress"][$selectedUpdate]."' "; $strSQL2 .=", Country = '".$_POST["ttCountry"][$selectedUpdate]."' "; $strSQL2 .=" where ID = '$selectedUpdate' "; $objQuery2 = mysql_query($strSQL2) or die(mysql_error()); } $strSQL = "SELECT * from member "; $objQuery = mysql_query($strSQL) or die ("Error Query [".$strSQL."]"); ?> <form name="frmMain" method="post" action="<?=$_SERVER["REQUEST_URI"];?>"> <input type="hidden" name="hdnCmd" value=""> <table width="800" border="0" align="center" cellpadding="3" cellspacing="1"> <tr> <td> </td> <td><strong>Date</strong></td> <td><strong>Name</strong></td> <td><strong>Address</strong></td> <td><strong>Country</strong></td> </tr> <? while($objResult = mysql_fetch_array($objQuery)) { ?> <tr> <td align="center"><label> <input type="submit" name="button" id="button" value="Save" OnClick="frmMain.hdnCmd.value='Update';frmMain.hddID.value='<?=$objResult["ID"];?>';frmMain.submit();"> </label></td> <td><?=$objResult["Dates"];?></td> <td><input name="ttName[<?=$objResult["ID"];?>]" type="text" value="<?=$objResult["Name"];?>" /></td> <td><input name="ttAddress[<?=$objResult["ID"];?>]" type="text" value="<?=$objResult["Address"];?>" /></td> <td><input name="ttCountry[<?=$objResult["ID"];?>]" type="text" value="<?=$objResult["Country"];?>" /></td> </tr> <? } ?> </table> <input name="hddID" type="hidden" value="" /> </form> <? mysql_close(); ?>
เพื่อความปลอดภัยของเว็บบอร์ด ไม่อนุญาติให้แทรก แท็ก [img]....[/img] โดยการอัพโหลดไฟล์รูปจากที่อื่น เช่นเว็บไซต์ ฟรีอัพโหลดต่าง ๆ อัพโหลดแทรกรูปภาพ ให้ใช้บริการอัพโหลดไฟล์ของไทยครีเอท และตัดรูปภาพให้พอดีกับสกรีน เพื่อความโหลดเร็วและไฟล์ไม่ถูกลบทิ้ง