|
|
|
เรียกข้อมูลที่ต้องการจะแก้ไขขึ้นมาได้ แต่ update ข้อมูล ลงใน ฐานข้อมูลไม่ได้ ค่ะ |
|
|
|
|
|
|
|
พอดีจะทำการ update ข้อมูลอะค่ะ ตอนแรกจะ search ข้อมูลขึ้นมาก่อน แล้วก้เลือกข้อมูลที่ต้องการแก้ไข จากนั้นหน้าข้อมูลที่จะทำการแก้ไข ก็จะมาโชว์ที่หน้า update2.php ค่ะ พอแก้ไขเสร็จก้จะ save ก็ save ได้ปกติ มัน echo ว่า "Save Done." แต่พอไปเช็คในฐานข้อมูลกลับไม่มีการ update ข้อมูลเกิดขึ้นเลยค่ะ เหมือนเดิม แต่ถ้าเปลี่ยนค่ะตัวแปรตรง where clause เป็นค่ะของมานเลยโดยตรงก็ update ได้ปกติค่ะ เลยคิดว่าน่าจะมีปัญหาเรื่องการส่งค่าตัวแปร ตรง where clause ช่วยหน่อยนะค่ะ
update2.php
<html>
<head>
<title>ThaiCreate.Com PHP & Access Tutorial</title>
</head>
<body>
<form action="update3.php?prject=<?=$_GET["prono"];?>" name="frmEdit" method="post"> <?
require_once("connect.php");
$strSQL = "SELECT * FROM project1_info WHERE prono = '".$_GET["prono"]."' ";
$objExec = odbc_exec($objConnect, $strSQL) ;
$objResult = odbc_fetch_array($objExec);
if(!$objResult)
{
echo "Not found CustomerID=".$_GET["prono"];
}
else
{
?>
<table width="847" cellspacing="4">
<tr>
<td bgcolor="#CCFFFF" class="style5"><span class="style6">Project Number<span class="style9"><strong>*</strong></span> </span></td>
<td><span class="style7">
<input name="prono" type="text" size="40" value="<?php echo $objResult["prono"];?>"disabled/>
</span> </td>
</tr>
<tr>
<td width="170" bgcolor="#CCFFFF"class="style5"><span class="style6">Project Name<span class="style9"><strong>*</strong></span></span></td>
<td width="659" ><input name="proj_name" type="text" size="40" value="<?php echo $objResult["proj_name"];?>"/></td>
</tr>
<tr>
<td bgcolor="#CCFFFF" class="style5"><span class="style6">Category<span class="style9">*</span></span> </td>
<td>
<select name="cat_id">
<option value="none" <?php if($objResult['cat_id'] == "0") { echo "selected" ; };?>>Choose One</option>
<option value="0" <?php if($objResult['cat_id'] == "0") { echo "selected" ; };?> >0</option>
<option value="1" <?php if($objResult['cat_id'] == "1") { echo "selected" ; };?> >1</option>
<option value="2" <?php if($objResult['cat_id'] == "2") { echo "selected" ; };?> >2</option>
<option value="3" <?php if($objResult['cat_id'] == "3") { echo "selected" ; };?> >3</option>
</select> </td>
</tr>
<tr>
<td bgcolor="#CCFFFF" class="style5"><span class="style6">Project Description<span class="style9"><strong>*</strong></span> </span></td>
<td ><textarea name="desc" cols="35" rows="5"><?php echo $objResult["description"];?></textarea>
</td>
</tr>
<tr>
<td bgcolor="#CCFFFF" class="style5"><span class="style6">Work Center <strong class="style9">*</strong></span></td>
<td>
<select name="plant">
<option value="none">- - - - - - - - - - - - - Choose One - - - - - - - - - - - - -</option>
<?php require_once("connect.php");
$sql_plant="select * from tb_plant order by plant_id ASC";
$exec_plant = odbc_exec($link, $sql_plant) or die ("Server cannot connection");
while(odbc_fetch_row($exec_plant)){
$plant_name=odbc_result($exec_plant,"plant_name");
$objResultt = odbc_fetch_array($plant_name);
?>
<option value="<?php echo $plant_name;?>" <?php if($objResult['plant'] == $plant_name) { echo "selected" ; }?> > <?php echo $plant_name; ?></option>
<?php }?>
</select>
<span class="style7">Other specify</span>
<input name="plant_other" type="text" size="15" value="<?php echo $objResult["plant_other"];?>"> </td>
</tr>
<tr>
<td bgcolor="#CCFFFF" class="style5"><span class="style6">Product Family<strong class="style9">*</strong> </span></td>
<td >
<select name="pro_family">
<option value="none">- - - - - - - - - - - - - Choose One - - - - - - - - - - - - -</option>
<?php require_once("connect.php");
$sql_family="select * from pro_family order by fname ASC";
$exec_family = odbc_exec($link, $sql_family) or die ("Server cannot connection");
while(odbc_fetch_row($exec_family)){
$fname=odbc_result($exec_family,"fname");
?>
<option value="<?php echo $fname; ?>" <?php if($objResult['pro_family'] == $fname) { echo "selected" ; }?>><?php echo $fname; ?></option>
<?php }?>
</select> </td>
</tr>
<tr>
<td bgcolor="#CCFFFF" class="style5"><span class="style6">Product Name<strong class="style9">*</strong> </span></td>
<td>
<table width="656">
<tr>
<td width="104" class="style7">Substrate:</td>
<td width="540">
<select name="index1">
<option value="none">Choose One</option>
<?php require_once("connect.php");
$sqlindex="select * from tb_index order by index_name ASC";
$execindex = odbc_exec($link, $sqlindex) or die ("Server cannot connection");
while(odbc_fetch_row($execindex)){
$index_id=odbc_result($execindex,"index_id");
$index_name=odbc_result($execindex,"index_name");
?>
<option value="<?php echo $index_name; ?>" <?php if($objResult['index1'] == $index_name) { echo "selected" ; }?>><?php echo $index_name; ?></option>
<?php }?>
</select> </td>
</tr>
<tr><td class="style7">HC1:</td>
<td>
<select name="hc1">
<option value="none">Choose One</option>
<?php
$sqlhc="select * from tb_hc order by hc_name ASC";
$exechc = odbc_exec($link, $sqlhc) or die ("Server cannot connection");
while(odbc_fetch_row($exechc)){
$hc_id=odbc_result($exechc,"hc_id");
$hc_name=odbc_result($exechc,"hc_name");
?>
<option value="<?php echo $hc_name; ?>" <?php if($objResult['hc1'] == $hc_name) { echo "selected" ; }?>><?php echo $hc_name; ?></option>
<?php }?>
</select> </td>
</tr>
<tr>
<td class="style7">AR1</td>
<td>
<select name="ar1" >
<option value="none">Choose One</option>
<?php
$sqlar="select * from tb_ar order by ar_name ASC";
$execar= odbc_exec($link, $sqlar) or die ("Server cannot connection");
while(odbc_fetch_row($execar)){
$ar_id=odbc_result($execar,"ar_id");
$ar_name=odbc_result($execar,"ar_name");
?>
<option value="<?php echo $ar_name; ?>" <?php if($objResult['ar1'] == $ar_name) { echo "selected" ; }?>><?php echo $ar_name; ?></option>
<?php }?>
</select> </td>
</tr>
<tr>
<td class="style7">Top coat1:</td>
<td>
<select name="tc1" >
<option value="none">Choose One</option>
<?php
$sqltc="select * from tb_tc order by tc_name ASC";
$exectc = odbc_exec($link, $sqltc) or die ("Server cannot connection");
while(odbc_fetch_row($exectc)){
$tc_id=odbc_result($exectc,"tc_id");
$tc_name=odbc_result($exectc,"tc_name");
?>
<option value="<?php echo $tc_name; ?>" <?php if($objResult['tc1'] == $tc_name) { echo "selected" ; }?>><?php echo $tc_name; ?></option>
<?php }?>
</select>
<a href=""> add more </a> </td>
</tr>
</table> </td>
</tr>
<tr>
<td bgcolor="#CCFFFF" class="style5"><span class="style6">Issue Date<strong class="style9">*</strong></span></td>
<td>
<select name="issue_date">
<option value="0" <?php if($objResult['issue_date'] == "0") { echo "selected" ; };?> >Date</option>
<option value="1" <?php if($objResult['issue_date'] == "1") { echo "selected" ; };?> >1</option>
<option value="2" <?php if($objResult['issue_date'] == "2") { echo "selected" ; };?> >2</option>
<option value="3" <?php if($objResult['issue_date'] == "3") { echo "selected" ; };?> >3</option>
<option value="4" <?php if($objResult['issue_date'] == "4") { echo "selected" ; };?> >4</option>
<option value="5" <?php if($objResult['issue_date'] == "5") { echo "selected" ; };?> >5</option>
<option value="6" <?php if($objResult['issue_date'] == "6") { echo "selected" ; };?> >6</option>
<option value="7" <?php if($objResult['issue_date'] == "7") { echo "selected" ; };?> >7</option>
<option value="8" <?php if($objResult['issue_date'] == "8") { echo "selected" ; };?> >8</option>
<option value="9" <?php if($objResult['issue_date'] == "9") { echo "selected" ; };?> >9</option>
<option value="10" <?php if($objResult['issue_date'] == "10") { echo "selected" ; };?> >10</option>
<option value="11" <?php if($objResult['issue_date'] == "11") { echo "selected" ; };?> >11</option>
<option value="12" <?php if($objResult['issue_date'] == "12") { echo "selected" ; };?> >12</option>
<option value="13" <?php if($objResult['issue_date'] == "13") { echo "selected" ; };?> >13</option>
<option value="14" <?php if($objResult['issue_date'] == "14") { echo "selected" ; };?> >14</option>
<option value="15" <?php if($objResult['issue_date'] == "15") { echo "selected" ; };?> >15</option>
<option value="16" <?php if($objResult['issue_date'] == "16") { echo "selected" ; };?> >16</option>
<option value="17" <?php if($objResult['issue_date'] == "17") { echo "selected" ; };?> >17</option>
<option value="18" <?php if($objResult['issue_date'] == "18") { echo "selected" ; };?> >18</option>
<option value="19" <?php if($objResult['issue_date'] == "19") { echo "selected" ; };?> >19</option>
<option value="20" <?php if($objResult['issue_date'] == "20") { echo "selected" ; };?> >20</option>
<option value="21" <?php if($objResult['issue_date'] == "21") { echo "selected" ; };?> >21</option>
<option value="22" <?php if($objResult['issue_date'] == "22") { echo "selected" ; };?> >22</option>
<option value="23" <?php if($objResult['issue_date'] == "23") { echo "selected" ; };?> >23</option>
<option value="24" <?php if($objResult['issue_date'] == "24") { echo "selected" ; };?> >24</option>
<option value="25" <?php if($objResult['issue_date'] == "25") { echo "selected" ; };?> >25</option>
<option value="26" <?php if($objResult['issue_date'] == "26") { echo "selected" ; };?> >26</option>
<option value="27" <?php if($objResult['issue_date'] == "27") { echo "selected" ; };?> >27</option>
<option value="28" <?php if($objResult['issue_date'] == "28") { echo "selected" ; };?> >28</option>
<option value="29" <?php if($objResult['issue_date'] == "29") { echo "selected" ; };?> >29</option>
<option value="30" <?php if($objResult['issue_date'] == "30") { echo "selected" ; };?> >30</option>
<option value="31" <?php if($objResult['issue_date'] == "31") { echo "selected" ; };?> >31</option>
</select>
/
<select name="issue_month">
<option value="1" <?php if($objResult['issue_month'] == "1") { echo "selected" ; };?> >1</option>
<option value="2" <?php if($objResult['issue_month'] == "2") { echo "selected" ; };?> >2</option>
<option value="3" <?php if($objResult['issue_month'] == "3") { echo "selected" ; };?> >3</option>
<option value="4" <?php if($objResult['issue_month'] == "4") { echo "selected" ; };?> >4</option>
<option value="5" <?php if($objResult['issue_month'] == "5") { echo "selected" ; };?> >5</option>
<option value="6" <?php if($objResult['issue_month'] == "6") { echo "selected" ; };?> >6</option>
<option value="7" <?php if($objResult['issue_month'] == "7") { echo "selected" ; };?> >7</option>
<option value="8" <?php if($objResult['issue_month'] == "8") { echo "selected" ; };?> >8</option>
<option value="9" <?php if($objResult['issue_month'] == "9") { echo "selected" ; };?> >9</option>
<option value="10" <?php if($objResult['issue_month'] == "10") { echo "selected" ; };?> >10</option>
<option value="11" <?php if($objResult['issue_month'] == "11") { echo "selected" ; };?> >11</option>
<option value="12" <?php if($objResult['issue_month'] == "12") { echo "selected" ; };?> >12</option>
</select>
/
<select name="issue_year">
<option value="0" <?php if($objResult['issue_year'] == "0") { echo "selected" ; };?> >Year</option>
<option value="2001" <?php if($objResult['issue_year'] == "2001") { echo "selected" ; };?> >2001</option>
<option value="2002" <?php if($objResult['issue_year'] == "2002") { echo "selected" ; };?> >2002</option>
<option value="2003" <?php if($objResult['issue_year'] == "2003") { echo "selected" ; };?> >2003</option>
<option value="2004" <?php if($objResult['issue_year'] == "2004") { echo "selected" ; };?> >2004</option>
<option value="2005" <?php if($objResult['issue_year'] == "2005") { echo "selected" ; };?> >2005</option>
<option value="2006" <?php if($objResult['issue_year'] == "2006") { echo "selected" ; };?> >2006</option>
<option value="2007" <?php if($objResult['issue_year'] == "2007") { echo "selected" ; };?> >2007</option>
<option value="2008" <?php if($objResult['issue_year'] == "2008") { echo "selected" ; };?> >2008</option>
<option value="2009" <?php if($objResult['issue_year'] == "2009") { echo "selected" ; };?> >2009</option>
<option value="2010" <?php if($objResult['issue_year'] == "2010") { echo "selected" ; };?> >2010</option>
<option value="2011" <?php if($objResult['issue_year'] == "2011") { echo "selected" ; };?> >2011</option>
<option value="2012" <?php if($objResult['issue_year'] == "2012") { echo "selected" ; };?> >2012</option>
<option value="2013" <?php if($objResult['issue_year'] == "2013") { echo "selected" ; };?> >2013</option>
<option value="2014" <?php if($objResult['issue_year'] == "2014") { echo "selected" ; };?> >2014</option>
<option value="2015" <?php if($objResult['issue_year'] == "2015") { echo "selected" ; };?> >2015</option>
<option value="2016" <?php if($objResult['issue_year'] == "2016") { echo "selected" ; };?> >2016</option>
<option value="2017" <?php if($objResult['issue_year'] == "2017") { echo "selected" ; };?> >2017</option>
<option value="2018" <?php if($objResult['issue_year'] == "2018") { echo "selected" ; };?> >2018</option>
<option value="2019" <?php if($objResult['issue_year'] == "2019") { echo "selected" ; };?> >2019</option>
<option value="2020" <?php if($objResult['issue_year'] == "2020") { echo "selected" ; };?> >2020</option>
<option value="2021" <?php if($objResult['issue_year'] == "2021") { echo "selected" ; };?> >2021</option>
<option value="2022" <?php if($objResult['issue_year'] == "2022") { echo "selected" ; };?> >2022</option>
<option value="2023" <?php if($objResult['issue_year'] == "2023") { echo "selected" ; };?> >2023</option>
<option value="2024" <?php if($objResult['issue_year'] == "2024") { echo "selected" ; };?> >2024</option>
<option value="2025" <?php if($objResult['issue_year'] == "2025") { echo "selected" ; };?> >2025</option>
<option value="2026" <?php if($objResult['issue_year'] == "2026") { echo "selected" ; };?> >2026</option>
<option value="2027" <?php if($objResult['issue_year'] == "2027") { echo "selected" ; };?> >2027</option>
<option value="2028" <?php if($objResult['issue_year'] == "2028") { echo "selected" ; };?> >2028</option>
<option value="2029" <?php if($objResult['issue_year'] == "2029") { echo "selected" ; };?> >2029</option>
<option value="2030" <?php if($objResult['issue_year'] == "2030") { echo "selected" ; };?> >2030</option>
<option value="2031" <?php if($objResult['issue_year'] == "2031") { echo "selected" ; };?> >2031</option>
<option value="2032" <?php if($objResult['issue_year'] == "2032") { echo "selected" ; };?> >2032</option>
<option value="2033" <?php if($objResult['issue_year'] == "2033") { echo "selected" ; };?> >2033</option>
<option value="2034" <?php if($objResult['issue_year'] == "2034") { echo "selected" ; };?> >2034</option>
<option value="2035" <?php if($objResult['issue_year'] == "2035") { echo "selected" ; };?> >2035</option>
<option value="2036" <?php if($objResult['issue_year'] == "2036") { echo "selected" ; };?> >2036</option>
<option value="2037" <?php if($objResult['issue_year'] == "2037") { echo "selected" ; };?> >2037</option>
<option value="2038" <?php if($objResult['issue_year'] == "2038") { echo "selected" ; };?> >2038</option>
<option value="2039" <?php if($objResult['issue_year'] == "2039") { echo "selected" ; };?> >2039</option>
<option value="2040" <?php if($objResult['issue_year'] == "2040") { echo "selected" ; };?> >2040</option>
<option value="2041" <?php if($objResult['issue_year'] == "2041") { echo "selected" ; };?> >2041</option>
<option value="2042" <?php if($objResult['issue_year'] == "2042") { echo "selected" ; };?> >2042</option>
<option value="2043" <?php if($objResult['issue_year'] == "2043") { echo "selected" ; };?> >2043</option>
<option value="2044" <?php if($objResult['issue_year'] == "2044") { echo "selected" ; };?> >2044</option>
<option value="2045" <?php if($objResult['issue_year'] == "2045") { echo "selected" ; };?> >2045</option>
<option value="2046" <?php if($objResult['issue_year'] == "2046") { echo "selected" ; };?> >2046</option>
<option value="2047" <?php if($objResult['issue_year'] == "2047") { echo "selected" ; };?> >2047</option>
<option value="2048" <?php if($objResult['issue_year'] == "2048") { echo "selected" ; };?> >2048</option>
<option value="2049" <?php if($objResult['issue_year'] == "2049") { echo "selected" ; };?> >2049</option>
<option value="2050" <?php if($objResult['issue_year'] == "2050") { echo "selected" ; };?> >2050</option>
<option value="2051" <?php if($objResult['issue_year'] == "2051") { echo "selected" ; };?> >2051</option>
<option value="2052" <?php if($objResult['issue_year'] == "2052") { echo "selected" ; };?> >2052</option>
<option value="2053" <?php if($objResult['issue_year'] == "2053") { echo "selected" ; };?> >2053</option>
<option value="2054" <?php if($objResult['issue_year'] == "2054") { echo "selected" ; };?> >2054</option>
<option value="2055" <?php if($objResult['issue_year'] == "2055") { echo "selected" ; };?> >2055</option>
<option value="2056" <?php if($objResult['issue_year'] == "2056") { echo "selected" ; };?> >2056</option>
<option value="2057" <?php if($objResult['issue_year'] == "2057") { echo "selected" ; };?> >2057</option>
<option value="2058" <?php if($objResult['issue_year'] == "2058") { echo "selected" ; };?> >2058</option>
<option value="2059" <?php if($objResult['issue_year'] == "2059") { echo "selected" ; };?> >2059</option>
<option value="2060" <?php if($objResult['issue_year'] == "2060") { echo "selected" ; };?> >2060</option>
</select> </td>
</tr>
<tr>
<td bgcolor="#CCFFFF" class="style5"><span class="style6">Design<span class="style9"><strong>*</strong></span></span></td>
<td><select name="design_list" id="design_list">
<option value="">Choose One</option>
<?php
require_once("connect.php");
$sqldesign="select * from tb_design order by design_name ASC";
$execdesign = odbc_exec($link, $sqldesign) or die ("Server cannot connection");
while(odbc_fetch_row($execdesign)){
$design_id=odbc_result($execdesign,"design_id");
$design_name=odbc_result($execdesign,"design_name");
?>
<option value="<?php echo $design_name; ?>" <?php if($objResult['design_list'] == $design_name) { echo "selected" ; }?>><?php echo $design_name; ?></option>
<?php }?>
</select></td>
</tr>
<tr>
<td bgcolor="#CCFFFF" class="style5"><span class="style6">Project Manager<strong class="style9">*</strong> </span></td>
<td > <input name="pro_manager" type="text" size="40" value="<?php echo $objResult["pro_manager"];?>" /></td>
</tr>
<tr>
<td bgcolor="#CCFFFF" class="style5"><span class="style6">Project Coordinator<strong class="style9">*</strong> </span></td>
<td><input name="pro_coor" type="text" size="40" value="<?php echo $objResult["pro_coor"];?>"/></td>
</tr>
<tr>
<td class="style7"> </td>
<td>
<input type="submit" name="Submit" value="Save" />
<input type="reset" name="reset" value="Reset" />
</td>
</tr>
<tr><td class="style7"> </td>
<td> </td>
</tr>
<tr bgcolor="#CCFFFF" class="style5">
<td colspan="2"><span class="style2 style8">Note! <strong> '<span class="style9">*</span>' is madatory field.</strong> </span></td>
</tr>
</table>
<?
}
odbc_close($objConnect);
?>
</form>
</body>
</html>
update3.php
<html>
<head>
<title>ThaiCreate.Com PHP & Access Tutorial</title>
</head>
<body>
<?
require_once("connect.php");
$prono1 = $_GET["prono"];
$prono2 = $_POST['prono'];
$proj_name = $_POST['proj_name'];
$cat_id = $_POST['cat_id'];
$description = $_POST['desc'];
$plant = $_POST['plant'];
$plant_other = $_POST['plant_other'];
$pro_family = $_POST['pro_family'];
$index1 = $_POST['index1'];
$hc1 = $_POST['hc1'];
$ar1 = $_POST['ar1'];
$tc1 = $_POST['tc1'];
$issue_date = $_POST['issue_date'];
$issue_month = $_POST['issue_month'];
$issue_year = $_POST['issue_year'];
$design_list = $_POST['design_list'];
$pro_manager = $_POST['pro_manager'];
$pro_coor = $_POST['pro_coor'];
$strSQL = "UPDATE project1_info
SET proj_name = '$proj_name' ,
cat_id = '$cat_id' ,
description = '$description' ,
plant = '$plant' ,
plant_other = '$plant_other' ,
pro_family = '$pro_family' ,
index1 = '$index1' ,
hc1 = '$hc1' ,
ar1 = '$ar1' ,
tc1 = '$tc1' ,
issue_date = '$issue_date ' ,
issue_month = '$issue_month' ,
issue_year = '$issue_year' ,
design_list = '$design_list' ,
pro_manager = '$pro_manager' ,
pro_coor = '$pro_coor '
WHERE prono = '$prono' ";
$objExec = odbc_exec($objConnect, $strSQL) ;
if($objExec)
{
echo "Save Done.";
}
else
{
echo "Error Save [".$strSQL."]";
}
odbc_close($objConnect);
?>
</body>
</html>
รบกวนหน่อยนะค่ะ ขอด่วนเลยก้จะดีมากค่ะ หรือจะเมลล์มาตอบก็ได้นะคะ [email protected]
ขอบคุณค่ะ
Tag : - - - -
|
|
|
|
|
|
Date :
2009-05-20 15:55:58 |
By :
narakjung21 |
View :
1285 |
Reply :
3 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
เมาโค๊ด
|
|
|
|
|
Date :
2009-05-21 06:19:44 |
By :
mrAAA |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
เอาหลักการก็ได้ค่ะ ไม่ต้องดูโคดหมดหรอกจ้า
|
|
|
|
|
Date :
2009-05-21 08:04:13 |
By :
narakjung21 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
ลองเช็คค่า '$prono' ว่ามีค่าส่งมาให้ ก่อน update หรือเปล่า ลอง echo ออกมาดูก่อนก็ได้นะครับ ค่อย update หรือทางที่ดี ก็เช็คทุกค่า แต่ตัวหลักๆ ก็ '$prono' นี้ละครับ
|
|
|
|
|
Date :
2009-05-27 13:56:13 |
By :
ail2geal2 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Load balance : Server 05
|