update ลงฐานข้อมูลไม่ได้ครับ มันไม่ส่งค่าไอดี กับ วันที่ ช่วยดูให้หน่อยครับ
โค๊ดตามนี้ครับ
Code (PHP)
<?php ob_start() ?>
<?
include "../include/function.inc.php";
include "../include/config.inc.php";
?>
<?
switch($hidAction)
{
case "Edit":
$sql = "select * from tbl_tech where id_tech='$id_tech'";
$dbquery = mysql_db_query($dbname, $sql);
$result = mysql_fetch_array($dbquery);
if($file[1]!="") {
$date_scat.=date("U");
$tech_pdf=$date_scat."_tech.pdf";
copy ($file[1] ,"../pdf/tech/$tech_pdf");
chmod("../pdf/tech/$tech_pdf", 0644);
}
echo $sql="update tbl_tech set tech_detail='$tech_detail',id_name='$id_name',id_agen='$id_agen',tech_charge='$tech_charge',tech_pdf='$tech_pdf',date='$date',id_type='$id_type' where id_tech='$id_tech'";
$dbquery = mysql_db_query($dbname, $sql);
JSError(3, "", "show_tech.php");
mysql_close();
break;
} ?>
<html>
<head>
<?
include "../include/config.inc.php";
$sql = "select * from tbl_tech where id_tech='$id_tech'";
$dbquery = mysql_db_query($dbname, $sql);
$result = mysql_fetch_array($dbquery);
//$id_tech = $result[id_tech];
$tech_detail = $result[tech_detail];
$id_name = $result[id_name];
$id_agen = $result[id_agen];
$tech_charge = $result[tech_charge];
$tech_pdf = $result[tech_pdf];
$id_type = $result[id_type];
?>
ค่าที่ส่งไป
update tbl_tech set tech_detail='bbbbbbbbbbbbb',id_name='26',id_agen='19',tech_charge='bbbbbbbbbbbbb',tech_pdf='1295331598_tech.pdf',date='',id_type='3' where id_tech=''Tag : PHP, CakePHP
Date :
2011-01-18 13:13:37
By :
fujisawa10
View :
850
Reply :
6
รบกวนดูให้ทีครับ
Date :
2011-01-18 13:22:47
By :
fujisawa10
update tbl_tech set tech_detail='bbbbbbbbbbbbb',id_name='26',id_agen='19',tech_charge='bbbbbbbbbbbbb',tech_pdf='1295331598_tech.pdf',date='',id_type='3' where id_tech=''
$id_tech, $date ไม่มาครับ
แสดงว่าชื่อของ element ของฟอร์มที่ส่งค่ามาที่หน้านี้ นั้นอาจจะไม่ตรงกันหรือว่าชื่อผิด
ลองตรวจเช็คดูนะครับ
ลองรับแล้ว echo ออกมาดูเฉยๆก่อนก็ได้
Date :
2011-01-18 13:29:16
By :
iamatomix
ส่งค่าเข้ามาได้ครับ
ตอนแก้ไข ข้อมูลเก่ายังแสดงอยู่ แต่ตอน กดยืนยัน
ก็เป้นอย่างที่เห็นอะครับ มันไม่ส่งค่าไป
โค๊ดทั้งหมดครับ
Code (PHP)
<?php ob_start() ?>
<?
include "../include/function.inc.php";
include "../include/config.inc.php";
?>
<?
switch($hidAction)
{
case "Edit":
$sql = "select * from tbl_tech where id_tech='$id_tech'";
$dbquery = mysql_db_query($dbname, $sql);
$result = mysql_fetch_array($dbquery);
if($file[1]!="") {
$date_scat.=date("U");
$tech_pdf=$date_scat."_tech.pdf";
copy ($file[1] ,"../pdf/tech/$tech_pdf");
chmod("../pdf/tech/$tech_pdf", 0644);
}
echo $sql="update tbl_tech set tech_detail='$tech_detail',id_name='$id_name',id_agen='$id_agen',tech_charge='$tech_charge',tech_pdf='$tech_pdf',date='$date',id_type='$id_type' where id_tech='$id_tech'";
$dbquery = mysql_db_query($dbname, $sql);
//JSError(3, "", "show_tech.php");
mysql_close();
break;
} ?>
<html>
<head>
<?
include "../include/config.inc.php";
$sql = "select * from tbl_tech where id_tech='$id_tech'";
$dbquery = mysql_db_query($dbname, $sql);
$result = mysql_fetch_array($dbquery);
//$id_tech = $result[id_tech];
$tech_detail = $result[tech_detail];
$id_name = $result[id_name];
$id_agen = $result[id_agen];
$tech_charge = $result[tech_charge];
$tech_pdf = $result[tech_pdf];
$id_type = $result[id_type];
?>
<title>One-stop Control Panel</title>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<link href="css_admin.css" rel="stylesheet" type="text/css">
<script language="javascript" src="script/allfunction.js"></script>
<script type="text/javascript" src="ckeditor/ckeditor.js"></script>
</head>
<body bgcolor="#F5F5F5" >
<form action="<?=$PHP_SELF;?>" method="post" enctype="multipart/form-data" name="frm_edit" id="frm_edit">
<table width="100%" border="0" cellpadding="0" cellspacing="0" class="f13">
<tr>
<td width="30" height="25"></td>
<td valign="bottom"> <table border="0" cellspacing="0" cellpadding="0">
<tr>
<td height="26" valign="bottom"> <table border="0" cellpadding="0" cellspacing="0" class="tb_button" height="25" width="184">
<tr>
<td width="182" align="center" valign="middle" bgcolor="#FFFFFF"><img src="images/icon_edit.gif" width="16" height="16" align="absmiddle" ><strong> แก้ไข</strong><b>ข้อมูลบริการวิชาการ</b></td>
</tr>
</table> </td>
</tr>
</table></td>
</tr>
<tr bgcolor="#176B00">
<td height="4" colspan="2" valign="top" bgcolor="#FF9999"><img src="images/spacer.gif" width="1" height="1"></td>
</tr>
<tr>
<td height="10" valign="top"><img src="images/spacer.gif" width="1" height="1"></td>
<td valign="top"><img src="images/spacer.gif" width="1" height="1"></td>
</tr>
<tr>
<td></td>
<td align="left" valign="top"><table width="800" border="0" align="left">
<tr>
<td colspan="3" class="f11"> </td>
</tr>
<tr>
<td width="270" align="right" class="f11">ชื่อเรื่อง :</td>
<td colspan="2" class="f11"><input name="tech_detail" type="text" class="box" id="tech_detail" value="<?=$tech_detail;?>" size="150" maxlength="150"></td>
</tr>
<tr>
<td align="right" class="f11"> </td>
<td width="573" colspan="2" class="f11"> </td>
</tr>
<tr>
<td align="right" class="f11">หัวหน้าโครงการ :</td>
<td class="f11"><select name="id_name" id="id_name" style="width:300px">
<option value="">-- Choose --</option>
<?
include "include/config.inc.php";
$sql="select * from tbl_name order by id_name";
$dbquery=mysql_db_query($dbname,$sql);
while($result=mysql_fetch_array($dbquery)){
?>
<option value='<?=$result[id_name];?>'><?=$result[names];?></option>
<?
}
?>
</select></td>
<td class="f11"> </td>
</tr>
<tr>
<td align="right" class="f11"> </td>
<td class="f11"> </td>
<td class="f11"> </td>
</tr>
<tr>
<td align="right" class="f11">สังกัดหน่วยงาน :</td>
<td class="f11"><select name="id_agen" id="id_agen" style="width:300px">
<option value="">-- Choose --</option>
<?
include "include/config.inc.php";
$sql="select * from tbl_agen order by id_agen";
$dbquery=mysql_db_query($dbname,$sql);
while($result=mysql_fetch_array($dbquery)){
?>
<option value='<?=$result[id_agen];?>'><?=$result[agen];?></option>
<?
}
?>
</select></td>
</tr>
<tr>
<td align="right" class="f11"> </td>
<td class="f11"> </td>
</tr>
<tr>
<td align="right" class="f11">ค่าบริการ :</td>
<td class="f11"><input name="tech_charge" type="text" class="box" id="tech_charge" value="<?=$tech_charge;?>"></td>
</tr>
<tr>
<td align="right" class="f11"> </td>
<td class="f11"> </td>
</tr>
<tr>
<td align="right" class="f11">PDF :</td>
<td class="f11"><label for="tech_pdf">
<input name="file[1]" type="file" id="file[1]" onpropertychange="showPic(this)">
</label></td>
<td rowspan="4" class="f11"> </td>
</tr>
<tr>
<td align="right" class="f11"> </td>
<td class="f11"> </td>
</tr>
<tr>
<td align="right" class="f11">ประเภท :</td>
<td class="f11"><select name="id_type" id="id_type" style="width:300px">
<option value="">-- Choose --</option>
<?
include "include/config.inc.php";
$sql="select * from tbl_type order by id_type";
$dbquery=mysql_db_query($dbname,$sql);
while($result=mysql_fetch_array($dbquery)){
?>
<option value='<?=$result[id_type];?>'><?=$result[types];?></option>
<?
}
?>
</select></td>
</tr>
<tr>
<td class="f11"> </td>
<td class="f11"> </td>
</tr>
<tr>
<td colspan="3" class="f11"><table width="100%" border="0">
<tr>
<td width="43%" align="right"><input type="submit" name="Submit" value="แก้ไขข้อมูล" class="box2">
<input name="hidAction" type=hidden class="f12" value="Edit" size=20 maxlength=20>
<input name="id_tech" type=hidden class="f12" value="<?=$result[id_tech];?>" size=20 maxlength=20></td>
<td width="57%"><input name="cancle" type="reset" class="box3" id="cancle" value="cancel"></td>
</tr>
</table></td>
</tr>
</table></td>
</tr>
<tr>
<td height="1"><img height="1" width="30" src="/images/spacer.gif"></td>
<td><img height="1" width="234" src="/images/spacer.gif"></td>
</tr>
</table>
</form>
</body>
</html>
<?php ob_end_flush() ?>
Date :
2011-01-18 13:35:53
By :
fujisawa10
ช่วยดูให้หน่อยน่ะครับ
Date :
2011-01-18 13:54:32
By :
fujisawa10
โอย ติดมันไม่ส่งไอดี งงงงงงงงงงงงงงงงงงงงงงง
Date :
2011-01-18 14:20:45
By :
fujisawa10
ส่งค่ามา ข้อมูลขั้นน่ะครับ
แต่พอ update มันส่งค่าทุกตัวหมด ยกเว้น id_tech มันเลยอัพเดทไม่ได้
ผมหาไม่จอว่ามันผิดตรงไหน
Date :
2011-01-18 14:30:43
By :
fujisawa10
Load balance : Server 03