 |
|
โค้ดในส่วนนี้จะเป็นทั้ง insert และ update ในส่วนของ insert ได้ปกติครับแต่ update ไม่ได้ครับทั้งๆ ที่มีค่ามา
แล้วในส่วนของไฟล์นี้ผมให้มัน insert เสร็จแล้วไป update ค่า status ที่ get มาจาก N ให้เป็น Y ในอีกตาราง
url ค่าที่ส่งไปอีกไฟล์ครับ

Code (PHP)
<?php
session_start();
include('db_con/connect.php');
$sql = mysql_query("select * from tb_user where user_id='$_SESSION[login_true]'") or die ("Err Can not to result") ;
$rows = mysql_fetch_array($sql);
$user = $rows['user_citiid'];
$name = $rows['user_name'];
$strSQL="INSERT INTO tb_question_bene (citizen_id,name,sex,age,edu,work_age,status,service,behavior1,behavior2,process1,process2,process3,result1,result2,result3,conclude,comment)
VALUES
('$user','$name','$_POST[sex]','$_POST[age]','$_POST[edu]','$_POST[work]','$_POST[status]','$_POST[service]','$_POST[behavior1]','$_POST[behavior2]','$_POST[process1]','$_POST[process2]','$_POST[process3]','$_POST[result1]','$_POST[result2]','$_POST[result3]','$_POST[conclude]','$_POST[comment]')";
if($_GET["statusbene"]=='N')
{
$strSQL1 = "UPDATE check_menu SET status_bene = 'Y' WHERE menu_id = '".$_GET["menub"]."' ";
}
$objQuery1 = mysql_query($strSQL1);
$objQuery = mysql_query($strSQL);
if($objQuery)
{
echo"<script language='JavaScript'>";
echo"alert('ระบบได้ทำการบันทึกข้อมูลเรียบร้อยแล้ว');";
echo"window.location='../home.php';";
echo"</script>";
}
else
{
echo"<script language='JavaScript'>";
echo"alert('Error :: ไม่สามารถบันทึกข้อมูลได้ [".$strSQL."]');";
//echo"window.location='competitor.php?mode=frm';";
echo"</script>";
}
mysql_close();
?>
ในส่วนของ get อะครับที่ไม่ update เข้าไปอีกตาราง
Tag : PHP, MySQL
|
|
 |
 |
 |
 |
Date :
2013-06-25 10:36:54 |
By :
littlebeer |
View :
967 |
Reply :
9 |
|
 |
 |
 |
 |
|
|
|
 |