|
|
|
รบกวนพี่ช่วยดูโค๊ดทีครับ INSERT ธรรมดาค่าที่ส่งไปถูกแล้วแต่ลงไปฐานข้อมูลค่าทีเข้าในฐานมันผิดครับ |
|
|
|
|
|
|
|
หน้าที่ใช้กรอกครับ
Code (PHP)
<?
include "config.inc.php";
$id_news= $_GET["id_news"];
$con2 = mysql_connect($host,$username,$password);
if (!$con2)
{ die('Could not connect: ' . mysql_error()); }
mysql_select_db($database, $con2);
mysql_query("SET NAMES UTF8");
$sql = "SELECT * FROM (employee_depart INNER JOIN news_apply ON employee_depart.id_depart = news_apply.id_depart) INNER JOIN employee_type ON employee_type.id_employee_type = news_apply.id_employee_type WHERE id_news=".$id_news;
$result2 = mysql_query($sql);
$row2 = mysql_fetch_array($result2);
?>
<link rel="stylesheet" media="all" type="text/css" href="js/jquerydatepicker/jquery-ui.css" />
<link rel="stylesheet" media="all" type="text/css" href="js/jquerydatepicker/jquery-ui-timepicker-addon.css" />
<script type="text/javascript" src="js/jquerydatepicker/jquery-1.10.2.min.js"></script>
<script type="text/javascript" src="js/jquerydatepicker/jquery-ui.min.js"></script>
<script type="text/javascript" src="js/jquerydatepicker/jquery-ui-timepicker-addon.js"></script>
<script type="text/javascript" src="js/jquerydatepicker/jquery-ui-sliderAccess.js"></script>
<script src="SpryAssets/SpryValidationSelect.js" type="text/javascript"></script>
<link href="SpryAssets/SpryValidationSelect.css" rel="stylesheet" type="text/css" />
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>เพิ่มข้อมูลสมัครงาน</title>
</head>
<body>
<table width="200" border="0" cellpadding="0" cellspacing="0" align="center">
<tr>
<th scope="col"><img src="pic/index1368.jpg" width="1024" height="200" /></th>
</tr>
</table>
<form id="form1" name="form1" method="post" action="apply_insert.php">
<label for="level"></label>
<table width="664" border="0" align="center" cellpadding="4" cellspacing="2">
<tr>
<td colspan="4" bgcolor="#CCCCCC"><h3>< ข้อมูลผู้สมัคร</h3></td>
</tr>
<tr>
<td align="right" bgcolor="#EAEAEA">แผนก :</td>
<td bgcolor="#EAEAEA"><?=$row2['type_depart']?></td>
<td align="right" bgcolor="#EAEAEA">ตำแหน่ง :</td>
<td bgcolor="#EAEAEA"><?=$row2['type_employee']?></td>
</tr>
<tr>
<td width="238" align="right" bgcolor="#EAEAEA">ชื่อ : </td>
<td width="154" bgcolor="#EAEAEA"><input type="text" name="first_name" id="first_name" /></td>
<td width="69" align="right" bgcolor="#EAEAEA">สกุล :</td>
<td width="175" bgcolor="#EAEAEA"><input type="text" name="last_name" id="last_name" /></td>
</tr>
<tr>
<td align="right" bgcolor="#EAEAEA">เพศ :</td>
<td bgcolor="#EAEAEA" id="startdate2"><input name="sex" type="radio" id="sex" value="1" checked="checked" />
ชาย
<input type="radio" name="sex" id="radio3" value="2" />
<label for="sex"></label>
หญิง</td>
<td colspan="2" rowspan="12" bgcolor="#EAEAEA"> </td>
</tr>
<tr>
<td align="right" bgcolor="#EAEAEA">อายุ :</td>
<td bgcolor="#EAEAEA" id="startdate3"><label for="age"></label>
<input type="text" name="age" id="age" /></td>
</tr>
<tr>
<td align="right" bgcolor="#EAEAEA">หมายเลขบัตรประจำตัวประชาชน :</td>
<td bgcolor="#EAEAEA"><input type="text" name="id_employee" id="id_employee" /></td>
</tr>
<tr>
<td align="right" bgcolor="#EAEAEA">วันเกิด :</td>
<td bgcolor="#EAEAEA" id="startdate">
<script type="text/javascript">
$(function(){
$("#date_bird").datepicker({
dateFormat: 'yy-mm-dd',
numberOfMonths: 1,
});
});
</script>
<input type="text" name="date_bird" id="date_bird" value="" /></td>
</tr>
<tr>
<td align="right" valign="top" bgcolor="#EAEAEA">ที่อยู่ :</td>
<td bgcolor="#EAEAEA"><label for=""></label>
<textarea name="street" cols="21" rows="4" id="street"></textarea></td>
</tr>
<tr>
<td align="right" bgcolor="#EAEAEA">ตำบล : </td>
<td bgcolor="#EAEAEA"><label for="tombon"></label>
<input type="text" name="tombon" id="tombon" /></td>
</tr>
<tr>
<td align="right" bgcolor="#EAEAEA">อำเภอ :</td>
<td bgcolor="#EAEAEA"><label for="city"></label>
<input type="text" name="city" id="city" /></td>
</tr>
<tr>
<td align="right" bgcolor="#EAEAEA">จังหวัด :</td>
<td bgcolor="#EAEAEA"><label for="province"></label>
<input type="text" name="province" id="province" /></td>
</tr>
<tr>
<td align="right" bgcolor="#EAEAEA">รหัสไปรษณีย์ :</td>
<td bgcolor="#EAEAEA"><label for="zip"></label>
<input type="text" name="zip" id="zip" /></td>
</tr>
<tr>
<td align="right" bgcolor="#EAEAEA">ประเทศ : </td>
<td bgcolor="#EAEAEA"><label for="country"></label>
<input type="text" name="country" id="country" /></td>
</tr>
<tr>
<td align="right" bgcolor="#EAEAEA">โทรศัพท์มือถือ :</td>
<td bgcolor="#EAEAEA"><label for="phone"></label>
<input type="text" name="phone" id="phone" /></td>
</tr>
<tr>
<td align="right" bgcolor="#EAEAEA">E-mail :</td>
<td bgcolor="#EAEAEA"><label for="email"></label>
<input type="text" name="email" id="email" /></td>
</tr>
<tr>
<td colspan="4" bgcolor="#CCCCCC"> </td>
</tr>
</table>
<p> </p>
<p> </p>
<table width="900" border="0" align="center" cellpadding="4" cellspacing="2">
<tr>
<td colspan="5" bgcolor="#CCCCCC"><h3>< ประวัติการศึกษา</h3></td>
</tr>
<tr>
<td width="160" align="center" bgcolor="#EAEAEA"><strong>ระดับการศึกษา</strong></td>
<td width="242" align="center" bgcolor="#EAEAEA"><strong>ชื่อสถาบัน</strong></td>
<td width="144" align="center" bgcolor="#EAEAEA"><strong>ปีที่จบ</strong></td>
<td width="144" align="center" bgcolor="#EAEAEA"><strong>เกรดเฉลี่ย</strong></td>
<td width="176" align="center" bgcolor="#EAEAEA"><strong>คณะ/สาขา</strong></td>
</tr>
<tr>
<td bgcolor="#EAEAEA"><label for="college"></label>
<input type="text" name="level" id="textfield2" /></td>
<td bgcolor="#EAEAEA"><label for="yearend"></label>
<input type="text" name="college" id="textfield3" /></td>
<td bgcolor="#EAEAEA"><label for="grade"></label>
<input type="text" name="yearend" id="textfield4" /></td>
<td bgcolor="#EAEAEA"><label for="fucluty"></label>
<input type="text" name="grade" id="textfield5" /></td>
<td bgcolor="#EAEAEA"><label for="agework"></label>
<input type="text" name="fucluty" id="textfield6" /></td>
</tr>
<tr>
<td colspan="5" bgcolor="#CCCCCC"> </td>
</tr>
</table>
<p><br />
</p>
<table width="399" border="0" align="center" cellpadding="4" cellspacing="2">
<tr>
<td colspan="2" bgcolor="#CCCCCC"><h3><strong>< ประวัติการทำงาน</strong></h3></td>
</tr>
<tr>
<td width="152" align="right" bgcolor="#EAEAEA">อายุงาน :</td>
<td width="231" bgcolor="#EAEAEA"><label for="depart_last"></label>
<input type="text" name="agework" id="textfield7" />
ปี</td>
</tr>
<tr>
<td align="right" bgcolor="#EAEAEA">ตำแหน่งงานล่าสุด :</td>
<td bgcolor="#EAEAEA"><label for="typework_last"></label>
<input type="text" name="depart_last" id="textfield8" /></td>
</tr>
<tr>
<td align="right" bgcolor="#EAEAEA">ประเภทงานล่าสุด :</td>
<td bgcolor="#EAEAEA"><label for="company_last"></label>
<input type="text" name="typework_last" id="textfield9" /></td>
</tr>
<tr>
<td align="right" bgcolor="#EAEAEA">บริษัทงานล่าสุด :</td>
<td bgcolor="#EAEAEA"><label for="textfield10"></label>
<input type="text" name="company_last" id="textfield10" /></td>
</tr>
<tr>
<td colspan="2" bgcolor="#CCCCCC"> </td>
</tr>
</table>
<p align="center">
<input type="submit" name="button" id="button" value="apply" />
<input type="reset" name="button2" id="button2" value="reset" />
<input name="id_depart" type="hidden" id="id_depart" value="<?=$row2['id_depart']?>" />
<input name="id_employee_type" type="hidden" id="id_employee_type" value="<?=$row2['id_employee_type']?>" />
</p>
</form>
</body>
</html>
หน้าโค๊ดINSERT
Code (PHP)
<?
//echo"<pre>";
//print_r($_POST);
//echo"</pre>";
//exit;
include "config.inc.php";
$con = mysql_connect($host,$username,$password);
if (!$con)
{ die('Could not connect: ' . mysql_error()); }
mysql_select_db($database, $con);
mysql_query("SET NAMES UTF8");
$id_employee= $_POST["id_employee"];
$id_depart= $_POST["id_depart"];
$id_employee_type= $_POST["id_employee_type"];
$first_name= $_POST["first_name"];
$last_name= $_POST["last_name"];
$sex= $_POST["sex"];
$age= $_POST["age"];
$date_bird= $_POST["date_bird"];
$company= $_POST["company"];
$college= $_POST["college"];
$yearend= $_POST["yearend"];
$grade= $_POST["grade"];
$fucluty= $_POST["fucluty"];
$street= $_POST["street"];
$tombon= $_POST["tombon"];
$city= $_POST["city"];
$province= $_POST["province"];
$phone= $_POST["phone"];
$zip= $_POST["zip"];
$country= $_POST["country"];
$agework= $_POST["agework"];
$depart_last= $_POST["depart_last"];
$typework_last= $_POST["typework_last"];
$company_last= $_POST["company_last"];
$level= $_POST["level"];
$email= $_POST["email"];
$sql="INSERT INTO employee_apply(id_employee,id_depart,id_employee_type,first_name,last_name,sex,age,date_bird,street,tombon,city,province,zip,country,phone,email,level,college,yearend,grade,fucluty,agework,depart_last,typework_last,company_last,status_app)
VALUES('$id_employee','$id_depart','$id_employee_type','$first_name','$last_name','$sex','$age','$date_bird','$street','$tombon','$city','$province','$zip','$country','$phone','$email','$level','$college','$yearend','$grade','$fucluty','$agework','$depart_last','$typework_last','$company_last','1')";
if (!mysql_query($sql,$con))
{ die('Error: ' . mysql_error()); }
header("Location: index.php");
mysql_close($con);
?>
ค่าของ id_employee ที่ส่งมาถูกแล้วครับ
Code
Array
(
[id_employee] => 1579900445493
)
แต่เข้าฐานข้อมูลเป็นอีกอย่าง
Tag : PHP
|
|
|
|
|
|
Date :
2015-05-06 16:34:53 |
By :
narongsad |
View :
702 |
Reply :
5 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
คุณส่งตัวแปร $id_employee_type มา insert นิครับ
|
|
|
|
|
Date :
2015-05-06 16:41:38 |
By :
Who Am i |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
อ๋อถูกแล้วล่ะครับ เเค่ สับสนลำดับ ตัวแปรที่ insert ของคุณ กับในชื่อตัวแปรในฐานข้อมูล
|
|
|
|
|
Date :
2015-05-06 16:44:14 |
By :
Who Am i |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
มันเป็นเพราะอะไรกันครับ งง จริงๆ
|
|
|
|
|
Date :
2015-05-06 17:05:04 |
By :
narongsad |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
39. $sql="INSERT INTO employee_apply(id_employee,id_depart,id_employee_type,first_name,last_name,sex,age,date_bird,street,tombon,city,province,zip,country,phone,email,level,college,yearend,grade,fucluty,agework,depart_last,typework_last,company_last,status_app)
40.
VALUES('$id_employee','$id_depart','$id_employee_type','$first_name','$last_name','$sex','$age','$date_bird','$street','$tombon','$city','$province','$zip','$country','$phone','$email','$level','$college','$yearend','$grade','$fucluty','$agework','$depart_last','$typework_last','$company_last','1')";
echo $sql;
ลอง echo มาดูก่อนครับ
|
|
|
|
|
Date :
2015-05-06 19:13:34 |
By :
Chaidhanan |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Load balance : Server 02
|