|
|
|
UPDATE ข้อมูลจากการค้นหา โดย UPDATE ->status , note ใช้ radio button.. |
|
|
|
|
|
|
|
จะ UPDATE ข้อมูลจากการค้นหา โดย UPDATE ->status , note
ไม่ทราบว่าจะบันทึกยังไง
receive_motor.php
<? session_start(); ?>
<link href="main_style.css" rel="stylesheet" type="text/css">
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>ข้อมูลการรับรถ</title>
<? include "header.php"; ?>
<? include "s1.php"; ?>
<? include "script.php"; ?>
<? include "connect.php"; ?>
<div id="left_block1" align="left"><? include"menu.php";?></div>
<br /><br />
<div id="right_block">
<table style="font-size:14px;border-bottom:2px dotted #999999;" width="100%" >
<tr><td><img src="image/Motorcycle.png" width="30" height="30" /><b>บันทึกสถานะรถ</b></td></tr>
</table>
<br /><br />
<form name="frmSearch" method="get" action="<?=$_SERVER['SCRIPT_NAME'];?>">
<table width="599" align="center" style="font-size:14px" >
<br />
<!--<tr >
<th width="129" align="right"> วันที่ :</th>
<td width="204"><input name="txtKeyword1" type="text" id="txtKeyword1" value="<?=$_GET["txtKeyword1"];?>"> </td>
<th width="129" align="right">ถึงวันที่ :</th>
<td width="204"><input name="txtKeyword2" type="text" id="txtKeyword2" value="<?=$_GET["txtKeyword2"];?>"></td>
<td width="1"></td>
<td width="4"></th>
</tr>
--><tr>
<th align="right">เลขที่บิล :</th>
<td><input name="txtKeyword3" type="text" id="txtKeyword3" value="<?=$_GET["txtKeyword3"];?>"></td>
<th align="right">เลขเครื่อง :</th>
<td><input name="txtKeyword4" type="text" id="txtKeyword4" value="<?=$_GET["txtKeyword4"];?>"></td>
<td align="left"><input type="submit" value="ค้นหา"></td>
</tr>
</table>
</form>
<form action="11.php" method="post">
<?
$strSQL="SELECT M.branch_no,B.chassis_id,B.machine_id,M.date_order,B.brand,C.type_name,D.color_name,B.buy,A.brand_name,E.branch_name
FROM po_detail B, po_mas M,brand A,type C,color D,branch E
WHERE
B.po_id = m.po_id AND
A.brand_id = B.brand AND
C.type_id = B.type AND
D.color_id = B.color AND
M.branch_no = E.branch_no AND
(B.po_id LIKE '%".$_GET["txtKeyword3"]."%') AND
(B.machine_id LIKE '%".$_GET["txtKeyword4"]."%') ";
$objQuery = mysql_query($strSQL) or die ("Error Query [".mysql_error().$strSQL."]");
$count = mysql_num_rows($objQuery) ;
?>
<font size="2" face="Verdana, Geneva, sans-serif">จำนวนข้อมูลทั้งหมด <font color="#FF0000"><b><?=$count; ?></b></font> แถว
<p />
<table width="945" cellpadding="0" cellspacing="0" style="font-size:12px; font-family:Verdana, Geneva, sans-serif;">
<tr height="35" bgcolor="#CCFFFF">
<th> <div align="center">ลำดับ</div></th>
<th> <div align="center">เลขเครื่อง</div></th>
<th> <div align="center">เลขถัง</div></th>
<th> <div align="center">ยี่ห้อ</div></th>
<th> <div align="center">รุ่น</div></th>
<th> <div align="center">สี</div></th>
<th> <div align="center">ราคาซื้อ</div></th>
<th> <div align="center">สถานะ</div></th>
<th> <div align="center">หมายเหตุ</div></th>
</tr>
<?
$i=1;
while($objResult = mysql_fetch_array($objQuery))
{
$date_receive = $objResult["date_receive"];
$buy = $objResult["buy"];
$po_id = $objResult["po_id"];
$branch_name = $objResult["branch_name"];
if($i%2==0)
{
$bg = "#FFFFFF";
}
else
{
$bg = "#ebf0f0";
}
$date_receive;
$yy = substr($date_receive,0,4);
$mm = substr($date_receive,5,2);
$dd = substr($date_receive,8,2);
$date_receive = $dd.'/'.$mm.'/'.$yy;
?>
<tr height="40" align="center" bgcolor="<?=$bg;?>" >
<td align="center"><?=$i++;?>.</td>
<td align="left"><?=$objResult["machine_id"];?></td>
<td align="left"><?=$objResult["chassis_id"];?></td>
<td align="left"><?=$objResult["brand_name"];?></td>
<td align="left"><?=$objResult["type_name"];?></td>
<td align="left"><?=$objResult["color_name"];?></td>
<td align="center"><?=number_format($buy, 2, '.', ',');?></td>
<td align="center">
<input name="mee[<?=$i;?>]" id="mee<?=$i;?>_1" type="radio" value="1"/>ครบ
<input name="mee[<?=$i;?>]" id="mee<?=$i;?>_2" type="radio" value="2"/>ไม่ครบ
</td>
<td align="center"><input type="text" id="txtnote" name="txtnote" /></td>
</tr>
<input type="hidden" id="count" name="count" value="<?=$count;?>" />
<?
}
?>
</table>
<center><input type="submit" name="submit" value="บันทึกข้อมูล" class="button" style="font-size:14px; font-weight:800;" /></center>
</form>
</div>
11.php
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<? include"connect.php";?>
<?
$strSQL = "UPDATE po_detail SET ";
$strSQL .="status = '".$_POST["txtstatus"]."' ";
$strSQL .="note = '".$_POST["txtnote"]."' ";
$strSQL .="WHERE machine_id = '".$_GET["mID"]."' ";
$objQuery = mysql_query($strSQL);
if($objQuery)
{
echo "<script>alert('UPDATE ข้อมูลเรียบร้อยแล้ว');</script>";
}
else
{
echo "Error Save [".$strSQL."]";
}
mysql_close();
?>
Tag : PHP, MySQL
|
ประวัติการแก้ไข 2013-05-14 16:51:20
|
|
|
|
|
Date :
2013-05-14 16:49:56 |
By :
lookpla26 |
View :
2498 |
Reply :
1 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
ลองเอาไปปรับใช้ดูนะครับแนวคิดน่าจะประมาณนี้
form.php
<form method="post" action="get.php">
<?php for($i=1;$i<=5;$i++){?>
<label><input type="radio" name="Status<?=$i?>" value="1" checked> ครบ</label>
<label><input type="radio" name="Status<?=$i?>" value="2" >ไม่ครบ</label>
<input type="hidden" name="id[]" value="id<?=$i?>">
<hr>
<?php }?>
<input type="hidden" name="num" value="<?=$i-1?>">
<input type="submit" name="button" id="button" value="Submit">
</form>
get.php
<?php
$num = $_POST['num'];
$id = $_POST['id'];
$status = array();
for($i=1;$i<=$num;$i++){
array_push($status,$_POST['Status'.$i]);
}
echo "<pre>";
print_r($id);
print_r($status);
echo "</pre>";
foreach($id as $key => $val){
echo "UPDATE Table SET Status = '".$status[$key]."' WHERE id ='".$val."' <br>";
}
?>
|
|
|
|
|
Date :
2013-05-14 20:06:19 |
By :
Krungsri |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Load balance : Server 04
|