|
 |
|
**สอบถาม** เรื่อง การแก้ไขรายการ ที่สามารถเพิ่ม ลด งานได้นะครับ ไม่รู้จะเริ่มยังไงดี |
|
 |
|
|
 |
 |
|

จากรูปด้านบนนะครับ คือหน้าที่แก้ไข โปรเจคและงานในโปรเจคนั้นๆ ครับ ซึ่งสามารถแก้ไขได้ทุกอย่าง รวมทั้งการ เพิ่ม ลด งานด้วย การแก้ไขทั้งหมดผมทำได้ แล้วครับ ติดตรงที่ว่า ถ้าในการเพิ่มงานลดงานนี้ผม หาทางคิดไม่ออกว่า ถ้าลด จะไปลบออกจากฐานข้อมูลยังไงหรือถ้าจะเพิ่มงาน เพิ่มลงฐานข้อมูลยังไง เอาไรส่งไป ว่าพอจะมีแนวทางหรือตัวอย่างไหมครับผม คือตอนนี้ผมแค่ทำการแก้ไข ในการณีที่ไม่เพิ่มหรือลดงานครับ ขอบคุณล่วงหน้าครับ
แล้วนี้คือฐานข้อมูลที่เก็บครับ


นี้คือโค้ด ตอนแก้ไขครับ
Code (PHP)
if(isset($_GET['mode']) and $_GET['mode']=="editquote")
{
//echo $_GET['mode'];
$countwork_sql = "select * from tblquotation_detail where quid ='".$_POST['txtquteid']."'";
$countwork_query = mysql_query($countwork_sql);
$numwork_old = mysql_num_rows($countwork_query);
//echo $numwork_old;
//////////////////////////////////////////////////////////////////////////
$Quid = $_POST['txtquteid'];
$respon_name = $_POST['txtrespon'];
$editdate = date("Y-m-d");
$cusid = $_POST['selcus'];
$projname = $_POST['project_name'];
$picquote = $_POST['temppic'];
$numwork = $_POST['hdnMaxLine'];
$sum_total = $_POST['hdsum'];
$rate_tax = $_POST['hdrate'];
$optsig = $_POST['optsig'];
$editquote_sql = "update tblquotation set project_name = '$projname', cid = '$cusid', qusignature = $optsig, respon_name = '$respon_name', filelogo ='$picquote',";
$editquote_sql .= "work_num = $numwork, taxrate = $rate_tax, total_cost = $sum_total, edit_date = '$editdate' where quid = '$Quid'";
//echo $editquote_sql;
if(mysql_query($editquote_sql))
{
if($numwork == $numwork_old)
{
for($i=0;$i<$_POST['hdnMaxLine'];$i++)
{
$id_qude =$_POST['hdqude_id'][$i];
$workname = $_POST['txtnamework'][$i];
$num = $_POST['selnum'][$i];
$unit = $_POST['selunit'][$i];
$cost = $_POST['txtamonut'][$i];
$total = $_POST['txtamonut'][$i]*$_POST['selnum'][$i];
/*echo "hdqude_id[$i] = ".$_POST["hdqude_id"][$i]."<br>";
echo "txtnamework[$i] = ".$_POST["txtnamework"][$i]."<br>";
echo "selnum[$i] = ".$_POST["selnum"][$i]."<br>";
echo "selunit[$i] = ".$_POST["selunit"][$i]."<br>";
echo "txtamonut[$i] = ".$_POST["txtamonut"][$i]."<br>";
echo "total = ".$total."<br>";
echo "///////////////////////////////////////////////<br>";*/
$update_quote = "update tblquotation_detail set work_name = '$workname',amount = $num,unit = '$unit',cost = $cost,total = $total where qude_id = $id_qude";
/*echo $update_quote."<br>";
echo "/////////////////////////////////////////////////////////////<br>";*/
mysql_query($update_quote);
}//end for
}//end if($numwork == $numwork_old)
else if($numwork > $numwork_old)//กรณีเพิ่ม
{
echo "$numwork > $numwork_old";
}//end if($numwork > $numwork_old)
else if($numwork < $numwork_old)//กรณีลด
{
echo "$numwork < $numwork_old";
}//if($numwork < $numwork_old)
}//end if mysql_query($editquote_sql)
}
Tag : PHP, MySQL, HTML/CSS, JavaScript, jQuery

|
ประวัติการแก้ไข 2014-02-14 10:02:50
|
 |
 |
 |
 |
Date :
2014-02-14 10:01:11 |
By :
nutzaaclub |
View :
813 |
Reply :
1 |
|
 |
 |
 |
 |
|
|
|
 |
 |
|
 |
 |
 |
|
|
 |
 |
|
รบกวนด้วยครับ
|
 |
 |
 |
 |
Date :
2014-02-15 07:42:50 |
By :
nutzaaclub |
|
 |
 |
 |
 |
|
|
 |
 |
|
 |
 |
|
|
|

|
Load balance : Server 04
|