update ในส่วนของรูปไม่ได้คับ
<?php
require_once("function/function.php");
require_once("function/config.php");
require_once("getListbox.php");
require_once("selecthot_project.php");
require_once("class.upload.php");
if(isset($_GET['uid']) && (!isset($_POST['hot_project_group_id']))){
$hot_project_id = $_GET['uid'];
$SQL = "select * from hot_project where hot_project_id = '$hot_project_id' ";
$RS = mysql_query($SQL);
$arr = mysql_fetch_array($RS);
$hot_project_group_id = $arr['hot_project_group_id'];
$day = $arr['day'];
$month = $arr['month'];
$year = $arr['year'];
$hot_project_trader = $arr['hot_project_trader'];
$hot_project_name = $arr['hot_project_name'];
$area = $arr['area'];
$maindcode_table = $arr['maindcode_table'];
$msg_group_table = $arr['msg_group_table'];
$hot_project_price = $arr['hot_project_price'];
$hot_project_pricegroupid = $arr['hot_project_pricegroupid'];
$hot_project_promotion = $arr['hot_project_promotion'];
$address = $arr['address'];
$roadid = $arr['roadid'];
$province = $arr['province'];
$amphur = $arr['amphur'];
$tumbon = $arr['tumbon'];
$hot_project_phone = $arr['hot_project_phone'];
$hot_project_fax = $arr['hot_project_fax'];
$hot_project_www = $arr['hot_project_www'];
$hot_project_detail = $arr['hot_project_detail'];
$hot_project_detail2 = $arr['hot_project_detail2'];
$hot_project_detail3 = $arr['hot_project_detail3'];
$hot_project_download = $arr['hot_project_download'];
$hot_project_pic_title = $arr['hot_project_pic_title'];
$hot_project_pic1= $arr['hot_project_pic1'];
$hot_project_pic2 = $arr['hot_project_pic2'];
$hot_project_pic3= $arr['hot_project_pic3'];
$hot_project_pic4= $arr['hot_project_pic4'];
$hot_project_pic5 = $arr['hot_project_pic5'];
$hot_project_pic6= $arr['hot_project_pic6'];
$btn ="update";
//...
}else if(isset($_GET['uid']) && (isset($_POST['hot_project_group_id']))){
// msgbox('update');
$SQL ="UPDATE hot_project SET hot_project_group_id = '$_POST[hot_project_group_id]',
day = '$_POST[day]',
month = '$_POST[month]',
year = '$_POST[year]',
hot_project_trader = '$_POST[hot_project_trader]',
hot_project_name = '$_POST[hot_project_name]',
area = '$_POST[area]',
maindcode_table = '$_POST[maindcode_table]',
msg_group_table = '$_POST[msg_group_table]',
hot_project_price = '$_POST[hot_project_price]',
hot_project_pricegroupid = '$_POST[hot_project_pricegroupid]',
hot_project_promotion = '$_POST[hot_project_promotion]',
address = '$_POST[address]',
roadid = '$_POST[roadid]',
province = '$_POST[province]',
amphur = '$_POST[amphur]',
tumbon = '$_POST[tumbon]',
hot_project_phone = '$_POST[hot_project_phone]',
hot_project_fax = '$_POST[hot_project_fax]',
hot_project_www = '$_POST[hot_project_www]',
hot_project_detail = '$_POST[hot_project_detail]',
hot_project_detail2 = '$_POST[hot_project_detail2]',
hot_project_detail3 = '$_POST[hot_project_detail3]',
hot_project_download = '$_POST[hot_project_download]'
WHERE hot_project_id = '$_GET[uid]' ";
mysql_query($SQL);
if ((isset($_POST["edit"])) && ($_POST["edit"] == "edit_pass") && ($hot_project_pic_title != "") ){
$upload_image = new upload($_FILES['hot_project_pic_title'] ) ;
if ( $upload_image->uploaded ) {
$upload_image->process( "hotproject_upload" );
if ( $upload_image->processed ) {
$hot_project_pic_title = $upload_image->file_dst_name ;
$upload_image->clean();
}
} $sql = "update hot_project set hot_project_pic_title='$hot_project_pic_title' where hot_project_id = '$hot_project_id' ";
$result = mysql_query($sql) or die("Err hot_project_pic_title") ;
}
if ((isset($_POST["edit"])) && ($_POST["edit"] == "edit_pass") && ($hot_project_pic1 != "") ){
$upload_image = new upload($_FILES['hot_project_pic1'] ) ;
if ( $upload_image->uploaded ) {
$upload_image->process( "hotproject_upload" );
if ( $upload_image->processed ) {
$hot_project_pic1 = $upload_image->file_dst_name ;
$upload_image->clean();
}
} $sql = "update hot_project set hot_project_pic1='$hot_project_pic1' where hot_project_id = 'hot_project_id' ";
$result = mysql_query($sql) or die("Err hot_project_pic1") ;
}
if ((isset($_POST["edit"])) && ($_POST["edit"] == "edit_pass") && ($hot_project_pic2 != "") ){
$upload_image = new upload($_FILES['hot_project_pic2'] ) ;
if ( $upload_image->uploaded ) {
$upload_image->process( "hotproject_upload" );
if ( $upload_image->processed ) {
$hot_project_pic2 = $upload_image->file_dst_name ;
$upload_image->clean();
}
} $sql = "update hot_project set hot_project_pic2='$hot_project_pic2' where hot_project_id = 'hot_project_id' ";
$result = mysql_query($sql) or die("Err hot_project_pic2") ;
}
if ((isset($_POST["edit"])) && ($_POST["edit"] == "edit_pass") && ($hot_project_pic3 != "") ){
$upload_image = new upload($_FILES['hot_project_pic3'] ) ;
if ( $upload_image->uploaded ) {
$upload_image->process( "hotproject_upload" );
if ( $upload_image->processed ) {
$hot_project_pic3 = $upload_image->file_dst_name ;
$upload_image->clean();
}
} $sql = "update hot_project set hot_project_pic3='$hot_project_pic3' where hot_project_id = 'hot_project_id' ";
$result = mysql_query($sql) or die("Err hot_project_pic3") ;
}
if ((isset($_POST["edit"])) && ($_POST["edit"] == "edit_pass") && ($hot_project_pic4 != "") ){
$upload_image = new upload($_FILES['hot_project_pic4'] ) ;
if ( $upload_image->uploaded ) {
$upload_image->process( "hotproject_upload" );
if ( $upload_image->processed ) {
$hot_project_pic4 = $upload_image->file_dst_name ;
$upload_image->clean();
}
} $sql = "update hot_project set hot_project_pic4='$hot_project_pic4' where hot_project_id = 'hot_project_id' ";
$result = mysql_query($sql) or die("Err hot_project_pic3") ;
}
if ((isset($_POST["edit"])) && ($_POST["edit"] == "edit_pass") && ($hot_project_pic5 != "") ){
$upload_image = new upload($_FILES['hot_project_pic5'] ) ;
if ( $upload_image->uploaded ) {
$upload_image->process( "hotproject_upload" );
if ( $upload_image->processed ) {
$hot_project_pic5 = $upload_image->file_dst_name ;
$upload_image->clean();
}
} $sql = "update hot_project set hot_project_pic5='$hot_project_pic5' where hot_project_id = 'hot_project_id' ";
$result = mysql_query($sql) or die("Err hot_project_pic3") ;
}
if ((isset($_POST["edit"])) && ($_POST["edit"] == "edit_pass") && ($hot_project_pic6 != "") ){
$upload_image = new upload($_FILES['hot_project_pic6'] ) ;
if ( $upload_image->uploaded ) {
$upload_image->process( "hotproject_upload" );
if ( $upload_image->processed ) {
$hot_project_pic6 = $upload_image->file_dst_name ;
$upload_image->clean();
}
} $sql = "update hot_project set hot_project_pic6='$hot_project_pic6' where hot_project_id = 'hot_project_id' ";
$result = mysql_query($sql) or die("Err hot_project_pic6") ;
}
redirect();
}else if(isset($_POST['hot_project_group_id']) && (!isset($_GET['uid']))){
$hot_project_group_id = $_POST['hot_project_group_id'];
$day = $_POST['day'];
$month = $_POST['month'];
$year = $_POST['year'];
$hot_project_trader = $_POST['hot_project_trader'];
$hot_project_name = $_POST['hot_project_name'];
$area = $_POST['area'];
$maindcode_table = $_POST['maindcode_table'];
$msg_group_table = $_POST['msg_group_table'];
$hot_project_price = $_POST['hot_project_price'];
$hot_project_pricegroupid = $_POST['hot_project_pricegroupid'];
$hot_project_promotion = $_POST['hot_project_promotion'];
$address = $_POST['address'];
$roadid = $_POST['roadid'];
$province = $_POST['province'];
$amphur = $_POST['amphur'];
$tumbon = $_POST['tumbon'];
$hot_project_phone = $_POST['hot_project_phone'];
$hot_project_fax = $_POST['hot_project_fax'];
$hot_project_www = $_POST['hot_project_www'];
$hot_project_detail = $_POST['hot_project_detail'];
$hot_project_detail2 = $_POST['hot_project_detail2'];
$hot_project_detail3 = $_POST['hot_project_detail3'];
$hot_project_download = $_POST['hot_project_download'];
$hot_project_date = date('Y/m/d H:i:s');
if ((isset($_POST["ok"])) && ($_POST["ok"] == "ok_pass")) {
$upload_image = new upload($_FILES['hot_project_pic_title']) ;
if ( $upload_image->uploaded ) {
$upload_image->process( "hotproject_upload" );
if ( $upload_image->processed ) {
$hot_project_pic_title = $upload_image->file_dst_name ;
$upload_image->clean();
}
}
}
if ((isset($_POST["ok"])) && ($_POST["ok"] == "ok_pass")) {
$upload_image = new upload($_FILES['hot_project_pic1']) ;
if ( $upload_image->uploaded ) {
$upload_image->process( "hotproject_upload" );
if ( $upload_image->processed ) {
$hot_project_pic1 = $upload_image->file_dst_name ;
$upload_image->clean();
}
}
}
if ((isset($_POST["ok"])) && ($_POST["ok"] == "ok_pass")) {
$upload_image = new upload($_FILES['hot_project_pic2']) ;
if ( $upload_image->uploaded ) {
$upload_image->process( "hotproject_upload" );
if ( $upload_image->processed ) {
$hot_project_pic2 = $upload_image->file_dst_name ;
$upload_image->clean();
}
}
}
if ((isset($_POST["ok"])) && ($_POST["ok"] == "ok_pass")) {
$upload_image = new upload($_FILES['hot_project_pic3']) ;
if ( $upload_image->uploaded ) {
$upload_image->process( "hotproject_upload" );
if ( $upload_image->processed ) {
$hot_project_pic3 = $upload_image->file_dst_name ;
$upload_image->clean();
}
}
}
if ((isset($_POST["ok"])) && ($_POST["ok"] == "ok_pass")) {
$upload_image = new upload($_FILES['hot_project_pic4']) ;
if ( $upload_image->uploaded ) {
$upload_image->process( "hotproject_upload" );
if ( $upload_image->processed ) {
$hot_project_pic4 = $upload_image->file_dst_name ;
$upload_image->clean();
}
}
}
if ((isset($_POST["ok"])) && ($_POST["ok"] == "ok_pass")) {
$upload_image = new upload($_FILES['hot_project_pic5']) ;
if ( $upload_image->uploaded ) {
$upload_image->process( "hotproject_upload" );
if ( $upload_image->processed ) {
$hot_project_pic5 = $upload_image->file_dst_name ;
$upload_image->clean();
}
}
}
if ((isset($_POST["ok"])) && ($_POST["ok"] == "ok_pass")) {
$upload_image = new upload($_FILES['hot_project_pic6']) ;
if ( $upload_image->uploaded ) {
$upload_image->process( "hotproject_upload" );
if ( $upload_image->processed ) {
$hot_project_pic6 = $upload_image->file_dst_name ;
$upload_image->clean();
}
}
}
$SQL ="INSERT INTO hot_project (hot_project_group_id ,day,month,year,hot_project_trader,hot_project_name,area,maindcode_table,msg_group_table,hot_project_price,hot_project_pricegroupid,hot_project_promotion,address,roadid,province,amphur,tumbon,hot_project_phone,hot_project_fax,hot_project_www,hot_project_detail,hot_project_detail2,hot_project_detail3,hot_project_download,hot_project_pic_title,hot_project_pic1,hot_project_pic2,hot_project_pic3,hot_project_pic4,hot_project_pic5,hot_project_pic6,hot_project_date ) VALUES ('$hot_project_group_id', '$day','$month','$year','$hot_project_trader' ,'$hot_project_name','$area','$maindcode_table','$msg_group_table','$hot_project_price','$hot_project_pricegroupid','$hot_project_promotion','$address','$roadid','$province','$amphur','$tumbon','$hot_project_phone','$hot_project_fax','$hot_project_www','$hot_project_detail','$hot_project_detail2','$hot_project_detail3','$hot_project_download','$hot_project_pic_title','$hot_project_pic1','$hot_project_pic2','$hot_project_pic3','$hot_project_pic4','$hot_project_pic5','$hot_project_pic6','$hot_project_date'); ";
//echo $SQL;
mysql_query($SQL);
redirect();
}else{
$hot_project_group_id=0;
$day =0;
$month=0;
$year=0;
$hot_project_trader="";
$hot_project_name="";
$area ="";
$maindcode_table =0;
$msg_group_table =0;
$hot_project_price="";
$hot_project_pricegroupid=0;
$hot_project_promotion="";
$address="";
$roadid=0;
$province=0;
$amphur=0;
$tumbon=0;
$hot_project_phone="";
$hot_project_fax="";
$hot_project_www ="";
$hot_project_detail ="";
$hot_project_detail2="";
$hot_project_detail3 ="";
$hot_project_download="";
$hot_project_pic_title ="";
$hot_project_pic1="";
$hot_project_pic2 ="";
$hot_project_pic3="";
$hot_project_pic4="";
$hot_project_pic5 ="";
$hot_project_pic6="";
$btn ="add";
}
?>
<meta http-equiv="Content-Type" content="text/html; charset=windows-874">
<link href="styleecareasy.css" rel="stylesheet" type="text/css">
<link href="style.css" rel="stylesheet" type="text/css">
<FORM METHOD=POST ACTION="" enctype="multipart/form-data">
<TABLE border="0" align="center" cellpadding="3" cellspacing="1" bgcolor="#8DC919">
<tr>
<td colspan="2" bgcolor="#8DC919"><p align="center">MENU : HOT PROJECT :</p></td>
</tr>
<TR>
<TD align="right" valign="middle" bgcolor="#FFFFFF">ชื่อคอลัมม :</TD>
<TD bgcolor="#FFFFFF"><?php getListboxhotprojectgroup($hot_project_group_id); ?><font color="#FF0000">**</font></TD>
</TR>
<TR>
<TD align="right" valign="middle" bgcolor="#FFFFFF">วัน/เดือน/ปี :</TD>
<TD bgcolor="#FFFFFF">วันที่
<?php getListboxday($day); ?>
เดือน
<?php getListboxmonth($month); ?>
พ.ศ.
<?php getListboxyear($year); ?><font color="#FF0000">**</font></TD>
</TR>
<TR>
<TD align="right" valign="middle" bgcolor="#FFFFFF">ผู้ประกอบการ :</TD>
<TD bgcolor="#FFFFFF"><INPUT TYPE="text" NAME="hot_project_trader" VALUE="<?php echo $hot_project_trader;?>" size="50"><font color="#FF0000">**</font></TD>
</TR>
<TR>
<TD align="right" valign="middle" bgcolor="#FFFFFF">ชื่อโครงการ :</TD>
<TD bgcolor="#FFFFFF"><INPUT TYPE="text" NAME="hot_project_name" VALUE="<?php echo $hot_project_name;?>" size="50"><font color="#FF0000">**</font></TD>
</TR>
<TR>
<TD align="right" valign="middle" bgcolor="#FFFFFF">เนื้อที่ :</TD>
<TD bgcolor="#FFFFFF"><INPUT TYPE="text" NAME="area" VALUE="<?php echo $area;?>" size="50"></TD>
</TR>
<TR>
<TD align="right" valign="middle" bgcolor="#FFFFFF">พื้นที่ :</TD>
<TD bgcolor="#FFFFFF"><?php
echo "<form action=\"?\" method=\"post\">
";
echo '<span id="maindcode_tableDiv">';
echo "<select name=\"maindcode_table\" id=\"maindcode_table\" onchange=\"dochange('maindcode_table')\">
";
echo "<option value=\"$maindcode_table\">--------------</option>
" ;
echo "</select></span>
";
?><font color="#FF0000">**</font></TD>
</TR>
<TR>
<TD align="right" valign="middle" bgcolor="#FFFFFF">ประเภท :</TD>
<TD bgcolor="#FFFFFF"><?
echo '<span id="msg_group_tableDiv">';
echo "<select name=\"msg_group_table\" id=\"msg_group_table\" onchange=\"dochange('msg_group_table')\">
";
echo "<option value=\"$msg_group_table\">--------------</option>
" ;
echo "</select></span>
";
?><font color="#FF0000">**</font></TD>
</TR>
<TR>
<TD align="right" valign="middle" bgcolor="#FFFFFF">ราคา :</TD>
<TD bgcolor="#FFFFFF"><INPUT TYPE="text" NAME="hot_project_price" VALUE="<?php echo $hot_project_price;?>" size="30"><font color="#FF0000">**</font></TD>
</TR>
<TR>
<TD align="right" valign="middle" bgcolor="#FFFFFF">กลุ่มราคา :</TD>
<TD bgcolor="#FFFFFF"><?php getListboxhotprojectpricegroup($hot_project_pricegroupid); ?><font color="#FF0000">**</font></TD>
</TR>
<TR>
<TD align="right" valign="middle" bgcolor="#FFFFFF">โปรโมชั่น :</TD>
<TD bgcolor="#FFFFFF"><INPUT TYPE="text" NAME="hot_project_promotion" VALUE="<?php echo $hot_project_promotion;?>" size="50"></TD>
</TR>
<TR>
<TD align="right" valign="middle" bgcolor="#FFFFFF">ที่อยู่ :</TD>
<TD bgcolor="#FFFFFF"><INPUT TYPE="text" NAME="address" VALUE="<?php echo $address;?>" size="50"></TD>
</TR>
<TR>
<TD align="right" valign="middle" bgcolor="#FFFFFF">ถนน :</TD>
<TD bgcolor="#FFFFFF"><?php getListboxroad($roadid); ?><font color="#FF0000">**</font></TD>
</TR>
<TR>
<TD align="right" valign="middle" bgcolor="#FFFFFF">จังหวัด :</TD>
<TD bgcolor="#FFFFFF"><? echo "<form action=\"?\" method=\"post\">
";
echo '<span id="provinceDiv">';
echo "<select name=\"province\" id=\"province\" onchange=\"dowork('province')\">
";
echo "<option value=\"$province\">--------------</option>
" ;
echo "</select></span>
";
?><font color="#FF0000">**</font></TD>
</TR>
<TR>
<TD align="right" valign="middle" bgcolor="#FFFFFF">อำเภอ/เขต :</TD>
<TD bgcolor="#FFFFFF"><? echo '<span id="amphurDiv">';
echo "<select name=\"amphur\" id=\"amphur\" onchange=\"dowork('amphur')\">
";
echo "<option value=\"$amphur\">--------------</option>
" ;
echo "</select></span>
";
?><font color="#FF0000">**</font></TD>
</TR>
<TR>
<TD align="right" valign="middle" bgcolor="#FFFFFF">ตำบล/แขวง :</TD>
<TD bgcolor="#FFFFFF"><? echo '<span id="tumbonDiv">';
echo "<select name=\"tumbon\" id=\"tumbon\">
";
echo "<option value=\"$tumbon\">--------------</option>
" ;
echo "</select></span>
";
?><font color="#FF0000">**</font></TD>
</TR>
<TR>
<TD align="right" valign="middle" bgcolor="#FFFFFF">เบอร์โทร :</TD>
<TD bgcolor="#FFFFFF"><INPUT TYPE="text" NAME="hot_project_phone" VALUE="<?php echo $hot_project_phone;?>" size="50"><font color="#FF0000">**</font></TD>
</TR>
<TR>
<TD align="right" valign="middle" bgcolor="#FFFFFF">FAX :</TD>
<TD bgcolor="#FFFFFF"><INPUT TYPE="text" NAME="hot_project_fax" VALUE="<?php echo $hot_project_fax;?>" size="50"></TD>
</TR>
<TR>
<TD align="right" valign="middle" bgcolor="#FFFFFF">Website :</TD>
<TD bgcolor="#FFFFFF"><INPUT TYPE="text" NAME="hot_project_www" VALUE="<?php echo $hot_project_www;?>" size="50"></TD>
</TR>
<TR>
<TD align="right" valign="middle" bgcolor="#FFFFFF">เนื้อหา :</TD>
<TD bgcolor="#FFFFFF"><textarea name="hot_project_detail" cols="69" rows="6"><?php echo $hot_project_detail;?></textarea><font color="#FF0000">**</font></TD>
</TR>
<TR>
<TD align="right" valign="middle" bgcolor="#FFFFFF">เนื้อหา2 :</TD>
<TD bgcolor="#FFFFFF"><textarea name="hot_project_detail2" cols="69" rows="6"><?php echo $hot_project_detail2;?></textarea></TD>
</TR>
<TR>
<TD align="right" valign="middle" bgcolor="#FFFFFF">เนื้อหา3 :</TD>
<TD bgcolor="#FFFFFF"><textarea name="hot_project_detail3" cols="69" rows="6"><?php echo $hot_project_detail3;?></textarea></TD>
</TR>
<TR>
<TD align="right" valign="middle" bgcolor="#FFFFFF">รูปโชว์หน้าแรก :</TD>
<TD bgcolor="#FFFFFF"><INPUT TYPE="file" NAME="hot_project_pic_title" VALUE="<?php echo $hot_project_pic_title;?>" size="20"> <img src="hotproject_upload/<?php echo $arr["hot_project_pic_title"];?>" width="40" height="40"><input name="eidt" type="hidden" value="<?echo "$hot_project_pic_title";?>"><font color="#FF0000">**(เฉพาะไฟล์รูปภาพ .gif กับ .jpeg)</font></TD>
</TR>
<TR>
<TD align="right" valign="middle" bgcolor="#FFFFFF">รูปหน้าหลัก1 :</TD>
<TD bgcolor="#FFFFFF"><INPUT TYPE="file" NAME="hot_project_pic1" VALUE="<?php echo $hot_project_pic1;?>" size="20"> <img src="hotproject_upload/<?php echo $arr["hot_project_pic1"];?>" width="40" height="40"><input name="edit" type="hidden" value="<?echo "$hot_project_pic1";?>"><font color="#FF0000">(เฉพาะไฟล์รูปภาพ .gif กับ .jpeg)</font></TD>
</TR>
<TR>
<TD align="right" valign="middle" bgcolor="#FFFFFF">รูปหน้าหลัก2 :</TD>
<TD bgcolor="#FFFFFF"><INPUT TYPE="file" NAME="hot_project_pic2" VALUE="<?php echo $hot_project_pic2;?>" size="20"> <img src="hotproject_upload/<?php echo $arr["hot_project_pic2"];?>" width="40" height="40"><input name="edit" type="hidden" value="<?echo "$hot_project_pic2";?>"><font color="#FF0000">(เฉพาะไฟล์รูปภาพ .gif กับ .jpeg)</font></TD>
</TR>
<TR>
<TD align="right" valign="middle" bgcolor="#FFFFFF">รูปหน้าหลัก3 :</TD>
<TD bgcolor="#FFFFFF"><INPUT TYPE="file" NAME="hot_project_pic3" VALUE="<?php echo $hot_project_pic3;?>" size="20"> <img src="hotproject_upload/<?php echo $arr["hot_project_pic3"];?>" width="40" height="40"><input name="edit" type="hidden" value="<?echo "$hot_project_pic3";?>"><font color="#FF0000">(เฉพาะไฟล์รูปภาพ .gif กับ .jpeg)</font></TD>
</TR>
<TR>
<TD align="right" valign="middle" bgcolor="#FFFFFF">รูปหน้าหลัก4 :</TD>
<TD bgcolor="#FFFFFF"><INPUT TYPE="file" NAME="hot_project_pic4" VALUE="<?php echo $hot_project_pic4;?>" size="20"> <img src="hotproject_upload/<?php echo $arr["hot_project_pic4"];?>" width="40" height="40"><input name="edit" type="hidden" value="<?echo "$hot_project_pic4";?>"><font color="#FF0000">(เฉพาะไฟล์รูปภาพ .gif กับ .jpeg)</font></TD>
</TR>
<TR>
<TD align="right" valign="middle" bgcolor="#FFFFFF">รูปหน้าหลัก5 "</TD>
<TD bgcolor="#FFFFFF"><INPUT TYPE="file" NAME="hot_project_pic5" VALUE="<?php echo $hot_project_pic5;?>" size="20"> <img src="hotproject_upload/<?php echo $arr["hot_project_pic5"];?>" width="40" height="40"><input name="edit" type="hidden" value="<?echo "$hot_project_pic5";?>"><font color="#FF0000">(เฉพาะไฟล์รูปภาพ .gif กับ .jpeg)</font></TD>
</TR>
<TR>
<TD align="right" valign="middle" bgcolor="#FFFFFF">รูปหน้าหลัก6 :</TD>
<TD bgcolor="#FFFFFF"><INPUT TYPE="file" NAME="hot_project_pic6" VALUE="<?php echo $hot_project_pic6;?>" size="20"> <img src="hotproject_upload/<?php echo $arr["hot_project_pic6"];?>" width="40" height="40"><input name="edit" type="hidden" value="<?echo "$hot_project_pic6";?>"><font color="#FF0000">(เฉพาะไฟล์รูปภาพ .gif กับ .jpeg)</font></TD>
</TR>
<TR>
<TD align="right" valign="middle" bgcolor="#FFFFFF">รหัสดาวน์โหลด :</TD>
<TD bgcolor="#FFFFFF"><INPUT TYPE="text" NAME="hot_project_download" VALUE="<?php echo $hot_project_download;?>"></TD>
</TR>
<TR>
<TD colspan="2" bgcolor="ffffff"><div align="center"><INPUT TYPE="submit" VALUE="<?php echo $btn;?>"><input type="hidden" name="ok" value="ok_pass" /><input type="hidden" name="edit" value="edit_pass" /></div></TD>
</TR>
</TABLE>
</FORM>
<script type="text/javascript">
//AJAX
function Inint_AJAX()
{
try
{
return new ActiveXObject( "Msxml2.XMLHTTP" );
}
catch ( e )
{
};
try
{
return new ActiveXObject( "Microsoft.XMLHTTP" );
}
catch ( e )
{
};
try
{
return new XMLHttpRequest();
}
catch ( e )
{
};
alert( "XMLHttpRequest not supported" );
return null;
};
function dochange( obj )
{
var req = Inint_AJAX();
var maindcode_table = document.getElementById( 'maindcode_table' ).value;
if ( obj && obj.name == 'maindcode_table' ) //เมื่อทำการเลือกที่จังหวัดมา ให้เคลียร์ค่าอำเภอ
{
var msg_group_table = "";
}
else //เลือกรายการอื่น
{
var msg_group_table = document.getElementById( 'msg_group_table' ).value;
};
var data = "maindcode_table=" + maindcode_table + "&msg_group_table=" + msg_group_table;
req.onreadystatechange = function()
{
if ( req.readyState == 4 )
{
if ( req.status == 200 )
{
var datas = eval( '(' + req.responseText + ')' ); // JSON
document.getElementById( 'maindcode_tableDiv' ).innerHTML = datas[0].maindcode_table;
document.getElementById( 'msg_group_tableDiv' ).innerHTML = datas[0].msg_group_table;
};
};
};
req.open( "post" , "zone.php" , true ); //สร้าง connection
req.setRequestHeader( "Content-Type", "application/x-www-form-urlencoded" ); // set Header
req.send( data ); //ส่งค่า
};
function dowork( obj )
{
var req = Inint_AJAX();
var province = document.getElementById( 'province' ).value;
var tumbon = document.getElementById( 'tumbon' ).value;
if ( obj && obj.name == 'province' ) //เมื่อทำการเลือกที่จังหวัดมา ให้เคลียร์ค่าอำเภอ
{
var amphur = "";
}
else //เลือกรายการอื่น
{
var amphur = document.getElementById( 'amphur' ).value;
};
var data = "province=" + province + "&hur=" + amphur + "&tumbon=" + tumbon;
req.onreadystatechange = function()
{
if ( req.readyState == 4 )
{
if ( req.status == 200 )
{
var datas = eval( '(' + req.responseText + ')' ); // JSON
document.getElementById( 'provinceDiv' ).innerHTML = datas[0].province;
document.getElementById( 'amphurDiv' ).innerHTML = datas[0].amphur;
document.getElementById( 'tumbonDiv' ).innerHTML = datas[0].tumbon;
};
};
};
req.open( "post" , "province.php" , true ); //สร้าง connection
req.setRequestHeader( "Content-Type", "application/x-www-form-urlencoded" ); // set Header
req.send( data ); //ส่งค่า
};
//โหลดครั้งแรก
window.onload = function()
{
dochange( '' );
dowork( '' );
};
</script>
การจะทำหลายหน้าที่ในหน้าเดียวกัน ก็ต้องมีอะไรสักอย่างที่จะบอกว่าต้องทำอะำไร เช่น
ใส่ action เพิ่มเข้ามา ถ้าส่ง action เป็น insert ก็ไป insert ถ้าส่ง action เป็น edit ก็ไป edit
หลักการมันก็ตรงไปตรงมา ทำให้ถูกขั้นตอนก็ใช้ได้แล้ว
ลองไปประยุกต์ดู