|
 |
|
insert ข้อมูลลงในฐานข้อมูลได้ไม่ครบค่ะ insert com_id ลงในฐานข้อมูลไม่ได้ค่ะ ส่วนอันอื่นเข้าค่ะ com_id ทำเป็นเลข auto run |
|
 |
|
|
 |
 |
|
Code (PHP)
insert com_id ลงในฐานข้อมูลไม่ได้ค่ะ ส่วนอันอื่นเข้าค่ะ com_id ทำเป็นเลข auto run
///////////////////////////////หน้า form//////////////////////////////////////////
<body>
<form action="data.php" method="post">
<table width="478" border="1">
<tr>
<td colspan="2"><div align="center">เพิ่มรายละเอียดเครื่องคอมพิวเตอร์</div></td>
</tr>
<tr>
<td width="158">รหัสเครื่องคอมพิวเตอร์</td>
<?
require ("function.php");//เมื่อเกิด error จะไม่ทำงานต่อ แต่ include จะทำงานต่อ
connect_db();
$max = mysql_query("select max(com_id) from repair");
$total_max = mysql_result($max,0)+1;
if(strlen($total_max)==1)
$idrepair="0000".$total_max;
else if(strlen($total_max)==2)
$idrepair="000".$total_max;
else if(strlen($total_max)==3)
$idrepair="00".$total_max;
else if(strlen($total_max)==4)
$idrepair="0".$total_max;
else if(strlen($total_max)==5)
$idrepair=$total_max;
?>
<td width="304"><input type="text" name="com_id" id="com_id" value='<?=$idrepair;?>'disabled="disabled"/></td>
</tr>
<tr>
<td>ชื่อผู้นำมาซ่อม</td>
<td><input type="text" name="name_send" /></td>
</tr>
<tr>
<td>กลุ่มงาน</td>
<td>
<select name="sectionn">
<option value="1">อำนวยการ</option>
<option value="2">นโยบายและแผน</option>
<option value="3">บุคคล</option>
<option value="4">นิเทศฯ</option>
<option value="5">เอกชน</option>
</select> </td>
</tr>
<tr>
<td>วันที่</td>
<?php
$_month_name = array("01"=>"มกราคม", "02"=>"กุมภาพันธ์", "03"=>"มีนาคม",
"04"=>"เมษายน", "05"=>"พฤษภาคม", "06"=>"มิถุนายน",
"07"=>"กรกฎาคม", "08"=>"สิงหาคม", "09"=>"กันยายน",
"10"=>"ตุลาคม", "11"=>"พฤศจิกายน", "12"=>"ธันวาคม");
$vardate=date('Y-m-d');
$yy=date('Y');
$mm =date('m');$dd=date('d');
if ($dd<10){
$dd=substr($dd,1,2);
}
$date=$dd ." ".$_month_name[$mm]." ".$yy+= 543;
?>
<td><input type="text" name="send_day" id="date" value="<?=$date;?>"/>
<br /></td>
</tr>
<tr>
<td>เวลา</td>
<?php
/*time zone for correct time.*/
date_default_timezone_set('Asia/Bangkok');
?>
<td><input type="text" name="send_time" id="date" value="<?=date('H:i:s')?>"/> </tr>
<tr>
<td>ผู้รับซ่อม</td>
<td><input type="text" name="name_re" /></td>
</tr>
<tr>
<td>อาการเสีย</td>
<td><textarea name="data" cols="17" rows="3"></textarea></td>
</tr>
<tr>
<td colspan="2"><div align="center">
<input type="submit" name="Submit" value="Submit" />
<input type="reset" name="Reset" value="Reset" />
</div></td>
</tr>
</table>
</form>
////////////////////////////////////////////////////////หน้า insert/////////////////////////////////////////////////////////
<?php
require("function.php");
connect_db();
$result=mysql_query("insert into repair(com_id,name_send,sectionn,name_re,send_day,send_time,data ) values ('$_POST[com_id]','$_POST[name_send]','$_POST[sectionn]','$_POST[name_re]','$_POST[send_day]','$_POST[send_time]','$_POST[data]')");
mysql_close();
header("Location:index.php");
?>
Tag : - - - -

|
|
 |
 |
 |
 |
Date :
2009-10-12 16:12:38 |
By :
nungblack |
View :
980 |
Reply :
6 |
|
 |
 |
 |
 |
|
|
|
 |
 |
|
 |
 |
 |
|
|
 |
 |
|
$result ค่าที่อยู่ในตัวแปร มีครบมั้ยครับ
และลอง
Code (PHP)
echo $_POST[com_id]; //มีค่าอะไรมั้ย
|
 |
 |
 |
 |
Date :
2009-10-12 16:17:55 |
By :
panyapol |
|
 |
 |
 |
 |
|
|
 |
 |
|
 |
 |
 |
|
|
 |
 |
|
เมื่อวานทำ ค่าที่ส่งไปเข้าฐานข้อมูลครบนะค่ะ แต่วันนี้ ค่าของ cod_id ไม่เข้า
|
 |
 |
 |
 |
Date :
2009-10-12 16:27:51 |
By :
nungblack |
|
 |
 |
 |
 |
|
|
 |
 |
|
 |
 |
 |
|
|
 |
 |
|
ตรงบรรทัดที่ 100 ลองแก้เป็นอย่างนี้ดูนะครับ 
Code (PHP)
$result=mysql_query("insert into repair(com_id,name_send,sectionn,name_re,send_day,send_time,data ) values ('".$_POST[com_id]."','".$_POST[name_send]."','".$_POST[sectionn]."','".$_POST[name_re]."','".$_POST[send_day]."','".$_POST[send_time]."','".$_POST[data]."')");
|
 |
 |
 |
 |
Date :
2009-10-12 16:40:58 |
By :
onizike |
|
 |
 |
 |
 |
|
|
 |
 |
|
 |
 |
 |
|
|
 |
 |
|
ลองเปลี่ยนแล้วค่ะยังเหมือนเดิมค่ะ com_id ไม่เข้าฐานข้อมูล
|
 |
 |
 |
 |
Date :
2009-10-12 18:33:58 |
By :
nungblack |
|
 |
 |
 |
 |
|
|
 |
 |
|
 |
 |
 |
|
|
 |
 |
|
ขอโทษนะครับ ลืมอ่าน ถ้ากรณี com_id ในดาต้าเบส เป็น auto
ก็ไม่ต้อง insert ค่าเข้าไปครับ ทำเป็นค่าว่างไว้ด้วยเครื่องหมาย ' ' 
Code (PHP)
$result=mysql_query("insert into repair(com_id,name_send,sectionn,name_re,send_day,send_time,data ) values ('','".$_POST[name_send]."','".$_POST[sectionn]."','".$_POST[name_re]."','".$_POST[send_day]."','".$_POST[send_time]."','".$_POST[data]."')");
|
 |
 |
 |
 |
Date :
2009-10-12 21:17:16 |
By :
onizike |
|
 |
 |
 |
 |
|
|
 |
 |
|
 |
 |
 |
|
|
 |
 |
|
ได้แล้วค่ะ ขอบคุณค่ะ
|
 |
 |
 |
 |
Date :
2009-10-12 21:27:10 |
By :
nungblack |
|
 |
 |
 |
 |
|
|
 |
 |
|
 |
 |
|
|
|

|
Load balance : Server 05
|