|
|
|
เลือก Check box แต่ล่ะแถวแล้วให้ update ครับ |
|
|
|
|
|
|
|
รบกวนด้วยครับ พอดีว่าผม ต้องการทำ แบบว่า ติ๊ก Chackbox แล้ว ให้ update แค่ แถวที่ติิ๊กนะครับ อย่างเช่น เลือกข้อมูลมา 10 แถว แต่ว่า ติก update แค่ 2 แถว แล้วกรอกข้อมูล ให้ update แค่แถวที่เรา ติ๊กเลือก 2 แถวนะครับ
Code (PHP)
<tr>
<td><input name="accept1[]" type="checkbox" id="accept1[]" value= <?php echo $potest ;?> > </td>
<td><center><div class="form-group col-xl-100"><input type="text" name="quotation[]" id="quotation" value="<?php echo $resultpo["QUOTATOIN"];?>" class="form-control"></div></center></td>
<td><center><div class="form-group col-xl-100"><input type="text" name="vendorcdate[]" placeholder="2018-01-01" id="vendorcdate" value="<?php echo $resultpo["VCONFDATE"];?>" class="form-control"></div></center></td>
<td><center><div class="form-group col-xl-100"><input type="text" name="vendorcqty[]" id="vendorcqty" value="<?php echo $resultpo["VCONFQTY"];?>" class="form-control"></div></center></td>
<td><center><div class="form-group col-xl-100"><input type="text" name="invoice[]" id="invoice" value="<?php echo $resultpo["VINVNO"];?>" class="form-control"></div></center></td>
<td><center><?php echo $resultpo["STATUS"];?></center></td>
<td><center><?php echo $resultpo["PRIORITY"];?></center></td>
<td><font size = '2' color = 'red'> <b><center><?php if($resultpo['NEWITEM']=='Y') echo '✔';?></font></b></center></td>
<td><font size = '2' color = 'red'> <b><center><?php if($resultpo['CMAT']=='Y') echo '✔';?></font></b></center></td>
<td><font size = '2' color = 'red'> <b><center><?php if($resultpo['CDESC']=='Y') echo '✔';?></font></b></center></td>
<td><font size = '2' color = 'red'> <b><center><?php if($resultpo['CQTY']=='Y')?></font></b></center></td>
<td><font size = '2' color = 'red'> <b><center><?php if($resultpo['CPRICE']=='Y')?></font></b></center></td>
<td><font size = '2' color = 'red'> <b><center><?php if($resultpo['CDELDATE']=='Y')?></font></b></center></td>
<td><font size = '2' color = 'red'> <b><center><?php if($resultpo["CADDLINE"]=='Y')?></font></b></td>
<td><font size = '2' color = 'red'> <b><center><?php if($resultpo['CDELLINE']=='Y')?></font></b></center></td>
<td></td>
<td><center><?php echo $resultpo["PONO"];?></center></td>
<td><center><?php echo $resultpo["POLINE"];?></center></td>
<td><center><?php echo $resultpo["MATERIAL"];?></center></td>
<td><center><?php echo $resultpo["DESCR"];?></center></td>
<td><center><?php echo $resultpo["DRAWNO"];?></center></td>
<td><center><?php echo $resultpo["POQTY"];?></center></td>
<td><center><?php echo $resultpo["OPENQTY"];?></center></td>
<td><center><?php echo $resultpo["UPRICE"];?></center></td>
<td><center><?php echo $resultpo["TOTPRICE"];?></center></td>
<td><center><?php echo $resultpo["CUR"];?></center></td>
<td><center><?php echo DateThai ($resultpo["PODATE"]);?></center></td>
<td><center><?php echo DateThai ($resultpo["DELDATE"]);?></center></td>
<td><center><?php echo DateThai ($resultpo["NEWDUEDATE"]);?></center></td>
<td><center><?php echo DateThai ($resultpo["MRPDATE"]);?></center></td>
<td><center><?php echo $resultpo["QCCLASS"];?></center></td>
<td><center><?php echo $resultpo["NOTE"];?></center></td>
<div style="display:none"><input type="text" style="width:190px;" maxlength="100" name="potest[]" id='potest' value="<?php echo $resultpo["PONO"]; echo $_POST['PONO'];?>"></div>
<div style="display:none"><input type="text" style="width:190px;" maxlength="100" name="pono1[]" id='pono1' value="<?php echo $resultpo["PONO"]; echo $_POST['PONO'];?>"></div>
<div style="display:none"><input type="text" style="width:190px;" maxlength="100" name="poline[]" id='poline' value="<?php echo $resultpo["POLINE"]; echo $_POST['POLINE'];?>"></div>
<div style="display:none"><input type="text" style="width:190px;" maxlength="100" name="poline1[]" id='poline1' value="<?php echo $resultpo["POLINE"]; echo $_POST['POLINE'];?>"></div>
<div style="display:none"><input type="text" style="width:190px;" maxlength="100" name="posubline[]" id='posubline' value="<?php echo $resultpo["POSUBLINE"]; echo $_POST['POSUBLINE'];?>"></div>
<div style="display:none"><input type="text" style="width:190px;" maxlength="100" name="posubline1[]" id='posubline1' value="<?php echo $resultpo["POSUBLINE"]; echo $_POST['POSUBLINE'];?>"></div>
<div style="display:none"><input type="text" style="width:190px;" maxlength="100" name="status1[]" id='status1' value="<?php echo $resultpo["STATUS"]; echo $_POST['STATUS'];?>"></div>
</tr>
<?php
$i++;
}
?>
<?php
}
?>
<?php
}
?>
</tbody>
<div class="form-group col-xl-3">
<?php
if($_GET['status']=="NEW"||$_GET['status']=="PROCESS"||$_GET['status']=="PROCESS")
{
?>
<button style="margin-right: 3px;" type="submit" name="submit" value="update" class="btn-xs btn btn-warning edit " onClick="return confirm('Are you sure you want to update?')"><i class="fa fa-edit"></i>Update</button>
<?php
}
if($_GET['status']=="CHANGE")
{
?>
<button style="margin-right: 3px;" type="submit" name="submit" value="updatemax" class="btn-xs btn btn-warning edit " onClick="return confirm('Are you sure you want to working?')"><i class="fa fa-edit"></i>Update</button>
<?php
}
?>
</div>
</table>
<?php
$accept1=array();$poline1=array();$posubline1=array();$pono1=array();$posubline=array();$poline=array();$potest=array();$quotation=array();$vendorcdate=array();$vendorcqty=array();$invoice=array();
$i=0;
foreach ($_POST["quotation"] as $var)
{
$quotation[$i]=$var;$i++;
}
$i=0;
foreach($_POST["vendorcdate"] as $var)
{
$year=substr($var,6,4);
$month=substr($var,3,2);
$date=substr($var,0,2);
$vendorcdate[$i]=$year."-".$month."-".$date;
//echo $STDATE[$i]." st<br>";
$i++;
}
$i=0;
foreach($_POST["vendorcqty"] as $var)
{
$vendorcqty[$i]=$var;$i++;
}
$i=0;
foreach($_POST["invoice"] as $var)
{
$invoice[$i]=$var;$i++;
}
$i=0;
foreach($_POST["potest"] as $var)
{
$potest[$i]=$var;$i++;
}
$i=0;
foreach($_POST["poline"] as $var)
{
$poline[$i]=$var;$i++;
}
$i=0;
foreach($_POST["posubline"] as $var)
{
$posubline[$i]=$var;$i++;
}
$i=0;
foreach($_POST["pono1"] as $var)
{
$pono1[$i]=$var;$i++;
}
$i=0;
foreach($_POST["poline1"] as $var)
{
$poline1[$i]=$var;$i++;
}
$i=0;
foreach($_POST["posubline1"] as $var)
{
$posubline1[$i]=$var;$i++;
}
$i=0;
foreach($_POST["accept1"] as $var)
{
$accept1[$i]=$var;$i++;
}
/*$quotation=$_POST['quotation'];*/
/*$potest=$_POST['potest'];*/
/*$poline=$_POST['poline'];*/
/*$posubline=$_POST['posubline'];*/
$pono=$_POST['pono'];
/*$vendorcdate=sqlEscape ($_POST["vendorcdate"]);*/
/*$vendorcqty=sqlEscape ($_POST["vendorcqty"]);*/
$confdel=sqlEscape ($_POST["confdel"]);
/*$invoice=sqlEscape ($_POST["invoice"]);*/
$statusin=sqlEscape ($_POST["statusin"]);
$priority=sqlEscape ($_POST["priority"]);
if($_POST["submit"]=="update")
{
for($j=0;$j<$i;$j++)
{
/*$pono=$_POST["checkbox"];*/
$update="update PUR_POVEN SET
QUOTATOIN ='".$quotation[$j]."'
,VCONFDATE='".$vendorcdate[$j]."'
,VCONFQTY ='".$vendorcqty[$j]."'
,VINVNO = '".$invoice[$j]."'
,VDELBY = '$default'
,VACCNPODATE = NOW()
,VACCNPOBY = '$default'";
$update.="where PONO = ".$potest[$j]." AND POLINE = ".$poline[$j]." AND POSUBLINE = ".$posubline[$j]."";
$queryupdate=mysqli_query($conn, $update);
}
if ($queryupdate)
{
for($b=0;$b<$i;$b++)
{
$updatepo = "update PUR_POV SET STATUS = 'PROCESS'";
/*$updatepo.="where PONO = ".$potest[$j]." AND POLINE = ".$poline[$j]." AND POSUBLINE = ".$posubline[$j]." AND STATUS = 'NEW'";*/
$updatepo.="where PONO = ".$pono1[$b]." AND POLINE = ".$poline1[$b]." AND POSUBLINE = ".$posubline1[$b]." AND STATUS = 'NEW'";
$queryupdatepo=mysqli_query($conn,$updatepo);
}
if ($queryupdatepo)
{
echo "<script>alert('Update Complete ✔✔'); location.href='accept_edit.php?material=$material&potest=$potest';</script>";
}
else echo "<script>alert('Update queryupdatepo Fail!!!'); location.href='accept_edit.php?material=$material';</script>";return 0;
}
else echo "<script>alert('Update queryupdate Fail!!!'); location.href='accept_edit.php?material=$material';</script>";return 0;
}
ต้องใส่ประมาณไหนอ่ะครับ
Tag : PHP, Ms SQL Server 2008
|
|
|
|
|
|
Date :
2018-02-15 13:31:48 |
By :
owenback |
View :
650 |
Reply :
2 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
ตัดเฉพาะส่วนที่มีปัญหามาครับ เอามาหมดมันดูยาก
|
|
|
|
|
Date :
2018-02-15 14:15:00 |
By :
dudesaranyu |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
ขอโทษทีครับ ไม่รู้ว่า ผมมาถูกเปล่านะครับ
Code (PHP)
<td><input name="accept1[]" type="checkbox" id="accept1[]" value= <?php echo $potest ;?> > </td>
$accept1=array();$poline1=array();$posubline1=array();$pono1=array();$posubline=array();$poline=array();$potest=array();$quotation=array();$vendorcdate=array();$vendorcqty=array();$invoice=array();
$i=0;
foreach($_POST["accept1"] as $var)
{
$accept1[$i]=$var;$i++;
}
ชุด Update ครับ
if($_POST["submit"]=="update")
{
for($j=0;$j<$i;$j++)
{
/*$pono=$_POST["checkbox"];*/
$update="update PUR_POVEN SET
QUOTATOIN ='".$quotation[$j]."'
,VCONFDATE='".$vendorcdate[$j]."'
,VCONFQTY ='".$vendorcqty[$j]."'
,VINVNO = '".$invoice[$j]."'
,VDELBY = '$default'
,VACCNPODATE = NOW()
,VACCNPOBY = '$default'";
$update.="where PONO = ".$potest[$j]." AND POLINE = ".$poline[$j]." AND POSUBLINE = ".$posubline[$j]."";
$queryupdate=mysqli_query($conn, $update);
}
if ($queryupdate)
{
for($b=0;$b<$i;$b++)
{
$updatepo = "update PUR_POV SET STATUS = 'PROCESS'";
/*$updatepo.="where PONO = ".$potest[$j]." AND POLINE = ".$poline[$j]." AND POSUBLINE = ".$posubline[$j]." AND STATUS = 'NEW'";*/
$updatepo.="where PONO = ".$pono1[$b]." AND POLINE = ".$poline1[$b]." AND POSUBLINE = ".$posubline1[$b]." AND STATUS = 'NEW'";
$queryupdatepo=mysqli_query($conn,$updatepo);
}
if ($queryupdatepo)
{
echo "<script>alert('Update Complete ✔✔'); location.href='accept_edit.php?material=$material&potest=$potest';</script>";
}
else echo "<script>alert('Update queryupdatepo Fail!!!'); location.href='accept_edit.php?material=$material';</script>";return 0;
}
else echo "<script>alert('Update queryupdate Fail!!!'); location.href='accept_edit.php?material=$material';</script>";return 0;
}
แต่ตรงชุด Update จะใส่ยังไงนี้แหละครับ ขอบคุณครับ
|
|
|
|
|
Date :
2018-02-15 14:31:17 |
By :
owenback |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Load balance : Server 03
|