  | 
              
	              
	                
  
    
	 
        สอบถามครับเกี่ยวกับ multiupdate ครับคือหลังจากที่ีอัพเดทเสร็จผมจะให้ข้อมูลที่อัพเดท insert ไปยังอีกตางรางด้วยครับ     | 
   
  
    |   | 
   
 
 
 
	
		
			  | 
	   | 
	    | 
		
			  | 
	 
	
		
			  | 
		 		   | 
	  	    
          
            
			
	
			
			 
                ขอบคุณล่วงหน้าครับผม 
Code (PHP) 
<html>
<head>
<style>
table {
    border-collapse: collapse;
}
table, th, td {
    border: 1px solid black;
}
th {
    background-color: #4CAF50;
    color: white;
}
tr:hover {
	background-color: #FFDAB9
	}
/*tr:nth-child(even) {
	background-color: #f2f2f2
	}*/
</style>
</head>
<body>
<?php
$objConnect = mysql_connect("localhost","root","1234") or die("Error Connect to Database");
$objDB = mysql_select_db("mydatabase");
if($_GET["Action"] == "Submit")
{
	for($i=1;$i<=$_POST["hdnLine"];$i++)
	{
		$strSQL = "UPDATE customer SET ";
		$strSQL .="CustomerID = '".$_POST["txtCustomerID$i"]."' ";
		$strSQL .=",Name = '".$_POST["txtName$i"]."' ";
		$strSQL .=",Email = '".$_POST["txtEmail$i"]."' ";
		$strSQL .=",CountryCode = '".$_POST["txtCountryCode$i"]."' ";
		$strSQL .=",Budget = '".$_POST["txtBudget$i"]."' ";
		$strSQL .=",Used = '".$_POST["txtUsed$i"]."' ";
		$strSQL .="WHERE CustomerID = '".$_POST["hdnCustomerID$i"]."' ";
		$objQuery = mysql_query($strSQL);
	}
	
}
$strSQL = "SELECT * FROM customer WHERE MONTH(DateSave) BETWEEN MONTH(now())-1 AND MONTH(now()) ORDER BY CustomerID ASC";
$objQuery = mysql_query($strSQL) or die ("Error Query [".$strSQL."]");
?>
<form name="frmMain" method="post" action="multiupdate.php?Action=Submit">
<table width="800" border="1" align="center">
  <tr>
    <th width="91"> <div align="center">CustomerID </div></th>
    <th width="98"> <div align="center">Name </div></th>
    <th width="198"> <div align="center">Email </div></th>
    <th width="97"> <div align="center">CountryCode </div></th>
    <th width="59"> <div align="center">Budget </div></th>
    <th width="71"> <div align="center">Used </div></th>
  </tr>
<?php
$i =0;
while($objResult = mysql_fetch_array($objQuery))
{
	$i = $i + 1;
?>
  <tr>
    <td><div align="center">
	<input type="hidden" name="hdnCustomerID<?php echo $i;?>" size="5" value="<?php echo $objResult["CustomerID"];?>">
	<input type="text" name="txtCustomerID<?php echo $i;?>" size="5" value="<?php echo $objResult["CustomerID"];?>">
	</div></td>
    <td><input type="text" name="txtName<?php echo $i;?>" size="20" value="<?php echo $objResult["Name"];?>"></td>
    <td><input type="text" name="txtEmail<?php echo $i;?>" size="20" value="<?php echo $objResult["Email"];?>"></td>
    <td><div align="center"><input type="text" name="txtCountryCode<?php echo $i;?>" size="2" value="<?php echo $objResult["CountryCode"];?>"></div></td>
    <td align="right"><input type="text" name="txtBudget<?php echo $i;?>" size="5" value="<?php echo $objResult["Budget"];?>"></td>
    <td align="right"><input type="text" name="txtUsed<?php echo $i;?>" size="5" ></td>
  </tr>
<?php
}
?>
</table>
  <input type="submit" name="submit" value="Submit">
  <input type="hidden" name="hdnLine" value="<?php echo $i;?>">
</form>
<?php
mysql_close($objConnect);
?>
</body>
</html>
 
 
  Tag : PHP, MySQL               
                        | 
           
          
            | 
			
                             | 
           
          
            
              
                   | 
                   | 
                   | 
               
              
                   | 
                
                    
                      | Date :
                          2018-10-11 09:03:18 | 
                      By :
                          Lun2560 | 
                      View :
                          739 | 
                      Reply :
                          6 | 
                     
                  | 
                   | 
               
              
                   | 
                   | 
                   | 
               
              | 
           
          
            | 
			 | 
           
         
	    
		             | 
		
			  | 
	 
	
		
			  | 
		  | 
		
			  | 
		
			  | 
	 
 
              
  
          
		
     
		
	  
        
             | 
            | 
            | 
             | 
         
        
             | 
                       | 
          
            
               
                 ติดปัญหายังไงครับ                        
               
               | 
             
            
              
			                              
                              
              
                
                     | 
                     | 
                     | 
                 
                
                     | 
                  
                      
                        | Date :
                            2018-10-11 09:52:03 | 
                        By :
                            Chaidhanan | 
                         
                    | 
                     | 
                 
                
                     | 
                     | 
                     | 
                 
                | 
             
           
			         | 
             | 
         
        
             | 
            | 
             | 
             | 
         
          
	    
     
               
		
     
		
	  
        
             | 
            | 
            | 
             | 
         
        
             | 
                       | 
          
            
               
                 คือผมอยากให้เวลา update เสร็จแล้วให้เอาข้อมูลที่ update ไป insert ที่ table cutomer2 ด้วยครับ                        
               
               | 
             
            
              
			                              
                              
              
                
                     | 
                     | 
                     | 
                 
                
                     | 
                  
                      
                        | Date :
                            2018-10-11 10:49:32 | 
                        By :
                            Lun2560 | 
                         
                    | 
                     | 
                 
                
                     | 
                     | 
                     | 
                 
                | 
             
           
			         | 
             | 
         
        
             | 
            | 
             | 
             | 
         
          
	    
     
               
		
     
		
	  
        
             | 
            | 
            | 
             | 
         
        
             | 
                       | 
          
            
               
                 หลังจาก สั่ง update แล้ว ก็ สั่ง insert เลยก็เท่านั้นเองครับ 
 
หรือที่ทำไม่ได้ เพราะเขียนคำสั่ง insert ไม่เป็น 
เพราะโค๊ดชุดนีี้ ก็ก๊อปปี้เขามา                        
               
               | 
             
            
              
			                              
                              
              
                
                     | 
                     | 
                     | 
                 
                
                     | 
                  
                      
                        | Date :
                            2018-10-11 12:43:55 | 
                        By :
                            Chaidhanan | 
                         
                    | 
                     | 
                 
                
                     | 
                     | 
                     | 
                 
                | 
             
           
			         | 
             | 
         
        
             | 
            | 
             | 
             | 
         
          
	    
     
               
		
     
		
	  
        
             | 
            | 
            | 
             | 
         
        
             | 
                       | 
          
            
               
                 Code (PHP) 
<html>
<head>
<?php
$objConnect = mysql_connect("localhost","root","1234") or die("Error Connect to Database");
$objDB = mysql_select_db("mydatabase");
$strSQL = "SELECT * FROM customer  ";
$objQuery = mysql_query($strSQL) or die ("Error Query [".$strSQL."]");
$objResult = mysql_fetch_array($objQuery);
?>
<?php
while( $objResult = mysql_fetch_assoc($objQuery)){ 
?>
<table width="800" border="1" align="center">
  <tr>
    <th width="91"> <div align="center">CustomerID </div></th>
    <th width="98"> <div align="center">Name </div></th>
    <th width="198"> <div align="center">Email </div></th>
    <th width="97"> <div align="center">CountryCode </div></th>
    <th width="59"> <div align="center">Budget </div></th>
    <th width="71"> <div align="center">Used </div></th>
  </tr>
  <tr>
    <td><div align="center">
	<input type="hidden" name="hdnCustomerID<?php echo $i;?>" size="5" value="<?php echo $objResult["CustomerID"];?>">
	<input type="text" name="txtCustomerID<?php echo $i;?>" size="5" value="<?php echo $objResult["CustomerID"];?>">
	</div></td>
    <td><input type="text" name="txtName<?php echo $i;?>" size="20" value="<?php echo $objResult["Name"];?>"></td>
    <td><input type="text" name="txtEmail<?php echo $i;?>" size="20" value="<?php echo $objResult["Email"];?>"></td>
    <td><div align="center"><input type="text" name="txtCountryCode<?php echo $i;?>" size="2" value="<?php echo $objResult["CountryCode"];?>"></div></td>
    <td align="right"><input type="text" name="txtBudget<?php echo $i;?>" size="5" value="<?php echo $objResult["Budget"];?>"></td>
    <td align="right"><input type="text" name="txtUsed<?php echo $i;?>" size="5" ></td>
  </tr>
<?php
}
?>
</table>
<?php
mysql_close($objConnect);
?>
</body>
</html>
                        
               
               | 
             
            
              
			                
  ประวัติการแก้ไข 2018-10-13 13:36:39 2018-10-13 13:37:46              
                              
              
                
                     | 
                     | 
                     | 
                 
                
                     | 
                  
                      
                        | Date :
                            2018-10-12 16:11:08 | 
                        By :
                            Lun2560 | 
                         
                    | 
                     | 
                 
                
                     | 
                     | 
                     | 
                 
                | 
             
           
			         | 
             | 
         
        
             | 
            | 
             | 
             | 
         
          
	    
     
               
		
     
		
	  
        
             | 
            | 
            | 
             | 
         
        
             | 
                       | 
          
            
               
                 Code (PHP) 
$objResult = mysql_fetch_array($objQuery);
?>
<br/>
<?php
$p = $objResult["p_id"];
for($i=1;$i<=$p;$i++){ ?>
 
 
ข้างบนเปลี่ยนใหม่เป็นข้างล่าง 
 
Code (PHP) 
?>
<br/>
<?php
while( $objResult = mysql_fetch_assoc($objQuery)){ ?>
 
 
ใช้ for แล้วคุณจะอ้างอิง result ของ mysql ยังไงล่ะครับ ให้ใช้ while 
ส่วนรายละเอียดของ คำสั่ง เปิด document อ่านเอาหน่อนนะครับ ถ้าอยากจะก้าวหน้ามากกว่านี้                        
               
               | 
             
            
              
			                              
                              
              
                
                     | 
                     | 
                     | 
                 
                
                     | 
                  
                      
                        | Date :
                            2018-10-12 17:34:16 | 
                        By :
                            Chaidhanan | 
                         
                    | 
                     | 
                 
                
                     | 
                     | 
                     | 
                 
                | 
             
           
			         | 
             | 
         
        
             | 
            | 
             | 
             | 
         
          
	    
     
               
		
     
		
	     
	    
     
      		  
	
     | 
   
 
                 |