ส่งค่า id ไม่ไปครับ.ผมจะให้ส่งค่า id จากหน้า form ที่บันทึกอันแรกแล้วให้ส่งค่า id ไปยัง form อีกหน้าเพื่อให้บันทึกเข้า id ตัวเดิมอ่ะคับ
Code (PHP)
<?php
if($_POST['action']=="adds")
{
$id = $_POST['id'];
$bu_work_name = $_REQUEST['bu_work_name'];
$bu_work_employer = $_REQUEST['bu_work_employer'];
$bu_work_designer = $_REQUEST['bu_work_designer'];
$bu_work_contrac = $_REQUEST['bu_work_contrac'];
$bu_work_address = $_REQUEST['bu_work_address'];
$bu_work_conname = $_REQUEST['bu_work_conname'];
$bu_work_connum = $_REQUEST['bu_work_connum'];
$bu_work_consign = $_REQUEST['bu_work_consign'];
$bu_work_start = $_REQUEST['bu_work_start'];
$bu_work_end = $_REQUEST['bu_work_end'];
$bu_work_period = $_REQUEST['bu_work_period'];
$bu_work_tag = $_REQUEST['bu_work_tag'];
$bu_work_budget = $_REQUEST['bu_work_budget'];
$bu_work_prepay = $_REQUEST['bu_work_prepay'];
$bu_work_nonbudget = $_REQUEST['bu_work_nonbudget'];
$bu_work_penalty = $_REQUEST['bu_work_penalty'];
$bu_work_costcontrol = $_REQUEST['bu_work_costcontrol'];
$work_du_id = $_REQUEST['work_du_id'];
$work_year_id = $_REQUEST['work_year_id'];
$work_year_id = $_REQUEST['work_year_id'];
$sql = mysql_query("insert into work_building set bu_work_name = '$bu_work_name' , bu_work_employer = '$bu_work_employer' , bu_work_designer = '$bu_work_designer' , bu_work_contrac = '$bu_work_contrac' , bu_work_address = '$bu_work_address' , bu_work_conname = '$bu_work_conname' , bu_work_connum = '$bu_work_connum' , bu_work_consign = '$bu_work_consign' , bu_work_start = '$bu_work_start' , bu_work_end = '$bu_work_end' , bu_work_period = '$bu_work_period' , bu_work_tag = '$bu_work_tag' , bu_work_budget = '$bu_work_budget' , bu_work_prepay = '$bu_work_prepay' , bu_work_nonbudget = '$bu_work_nonbudget' , bu_work_penalty = '$bu_work_penalty' , bu_work_costcontrol = '$bu_work_costcontrol' , work_du_id = '$work_du_id' , work_year_id = '$work_year_id' , last_update = now()") or die(mysql_error());
if($sql){
$sql2 = mysql_query("insert into work_building_2 set bu_work_name = '$bu_work_name' , bu_work_employer = '$bu_work_employer' , bu_work_designer = '$bu_work_designer' , bu_work_contrac = '$bu_work_contrac' , bu_work_address = '$bu_work_address' , bu_work_conname = '$bu_work_conname' , bu_work_connum = '$bu_work_connum' , bu_work_consign = '$bu_work_consign' , bu_work_start = '$bu_work_start' , bu_work_end = '$bu_work_end' , bu_work_period = '$bu_work_period' , bu_work_tag = '$bu_work_tag' , bu_work_budget = '$bu_work_budget' , bu_work_prepay = '$bu_work_prepay' , bu_work_nonbudget = '$bu_work_nonbudget' , bu_work_penalty = '$bu_work_penalty' , bu_work_costcontrol = '$bu_work_costcontrol' , work_du_id = '$work_du_id' , work_year_id = '$work_year_id' , last_update = now()") or die(mysql_error());
if ($sql2) {echo "";}
else {echo "ERROR: " . $sql . "<br>" . $conn->error;}
}
else {echo "Error1: " . $sql . "<br>" . $conn->error;}
exit("<script>alert('เพิ่มข้อมูลเรียบร้อยแล้ว');window.location=\"forms_building_tag.php?id=$id\";</script>");
}
?>
ผมจะให้ส่งค่า id จากหน้า form ที่บันทึกอันแรกแล้วให้ส่งค่า id ไปยัง form อีกหน้าเพื่อให้บันทึกเข้า id ตัวเดิมอ่ะคับTag : PHP, MySQL
Date :
2015-05-07 10:16:44
By :
stepartz
View :
689
Reply :
1
1.php
Code (PHP)
<?php
if( isset($_REQUEST['save'])){
$sql = mysql_query( 'insert into ....');
$id=myql_insert_id();
header('location: 2.php?id='.$id);
exit;
}
?>
<!doctype html>
<html>
<body>
<form>
......
<input type=submit name=save value=save>
</fomr>
Date :
2015-05-07 10:53:43
By :
Chaidhanan
Load balance : Server 00