|  | 
	                
  
    | 
	 
        ใช้คำสั่ง update sql สามารถใช้ได้แต่มันแก้ไขทุกบรรทัดเหมือนกันหมดครับจะทำยังดีครับ     |  
    |  |  
 
              
  
    | 
 
        
          |  |  |  |  |  
          |  |  | 
            
              | code ครับ ผิดตรงไหนเหรอครับ 
 <?php
 include"db_setup.php"; //--->ไฟล์สำหรับเชื่อมต่อฐานข้อมูลที่นำเข้ามา
 ?>
 
 <?php
 //เลือกฐานข้อมูล
 mysql_select_db($dbname) or die("เลือกฐานข้อมูลไม่ได้");
 
 //ประกาศตัวแปร
 $tb="list";//--->list คือชื่อตาราง
 
 $sql="update $tb set status='$status',pay_no='$pay_no',user_name='$user_name',post_no='$post_no',post_type='$post_type',date='$date where no='$no";
 
 $dbquery=mysql_db_query($dbname,$sql);
 >
 
 |  
              | 
                
                  |  |  |  |  
                  |  | 
                      
                        | Date :
                            2011-08-01 14:25:55 | By :
                            อลันด์ |  |  |  
                  |  |  |  |  |  |  |  
          |  |  |  |  |  
 
        
          |  |  |  |  |  
          |  |  | 
            
              | ตรวจสอบค่า $no 
 echo "$sql";
 
 |  
              | 
                
                  |  |  |  |  
                  |  | 
                      
                        | Date :
                            2011-08-01 14:32:38 | By :
                            noomthapla |  |  |  
                  |  |  |  |  |  |  |  
          |  |  |  |  |  
 
        
          |  |  |  |  |  
          |  |  | 
            
              | ตรงลิ้งค์ "แก้ไข" คุณเขียนยังไงหรอครับ? ประมาณนี้ไม๊ Code (PHP)
 
 <a href="edit.php?no=<?=$result['no'];?>">แก้ไข</a>
 
 และหน้าที่ทำการส่งไปจากฟอร์ม (action)
 ประกาศตัวแปรไว้ประมาณนี้ไม๊?
 
 $no = $_GET['no'];
 
 ถ้าตามนี้ก็น่าจะได้นะผมว่า ถ้าไม่ใช่ตามนี้ลองแก้ดูครับ
 
 |  
              | 
                
                  |  |  |  |  
                  |  | 
                      
                        | Date :
                            2011-08-01 14:39:29 | By :
                            arm8957 |  |  |  
                  |  |  |  |  |  |  |  
          |  |  |  |  |  
 
        
          |  |  |  |  |  
          |  |  | 
            
              | ลงตัวแปร id ไปรึยัง 
 |  
              | 
                
                  |  |  |  |  
                  |  | 
                      
                        | Date :
                            2011-08-01 15:03:44 | By :
                            avsqlz |  |  |  
                  |  |  |  |  |  |  |  
          |  |  |  |  |  
 
 
        
          |  |  |  |  |  
          |  |  | 
            
              | เอาโค้ดมาดูได้ป่าวคับ 
 |  
              | 
                
                  |  |  |  |  
                  |  | 
                      
                        | Date :
                            2011-08-01 16:18:55 | By :
                            arm8957 |  |  |  
                  |  |  |  |  |  |  |  
          |  |  |  |  |  
 
        
          |  |  |  |  |  
          |  |  | 
            
              | list_orders_admin.php 
 <?php
include"db_setup.php"; //--->ไฟล์สำหรับเชื่อมต่อฐานข้อมูลที่นำเข้ามา
?>
<?php
//เลือกฐานข้อมูล
mysql_select_db($dbname) or die("เลือกฐานข้อมูลไม่ได้");
//ประกาศตัวแปร
$tb="list";//--->list คือชื่อตาราง
$sql="select * from $tb where no=$no";
$dbquery=mysql_db_query($dbname,$sql);
$row=mysql_fetch_array($dbquery);
$no=$no;
$pay_no=$row['pay_no'];
$user_name=$row['user_name'];
$post_no=$row['post_no'];
#$post_type=$row['post_type'];
$date=$row['date'];
#$status=$row['status'];
mysql_close();
?>
<style type="text/css">
.b {	font-weight: bold;
}
.b {	font-weight: normal;
}
.blue {	color: #03C;
}
.color {	color: #F00;
}
.center form p {
	font-size: 16px;
	font-weight: bold;
	text-align: center;
}
.center form input {
	text-align: center;
}
center {
	text-align: center;
}
.center form {
	text-align: center;
}
</style>
<body class="center"><p> </p>
<p> </p>
<p> </p>
<p> </p>
<p> </p>
<form name="form1" method="post" action="edit_orders.php">
<!-- กำหนดไฟล์ที่รับข้อมูลจากฟอร์ม -->
  <p class="color"> </p>
  แก้ไขข้อมูล ลำดับที่ <font color=red><?php print($no);?></font><br>
  <br>
  <table width="750" border="0" align="center" cellpadding="1" cellspacing="1">
    <tr>
      <td width="350" height="25" bgcolor="#CCCCCC" class="b"30"><strong>    เลขที่ใบสั่งซื้อ<span class="color"> <span class="blue">(8 หลัก)</span></span> :</strong></td>
      <td width="350" height="25" bgcolor="#CCCCCC">  
        <input name="pay_no" type=text value="<?php print($pay_no);?>"></td>
        
    </tr>
    <tr>
      <td height="25" bgcolor="#EEEEEE" class="b"><strong>   ชื่อสมาชิก :</strong></td>
      <td height="25" bgcolor="#EEEEEE">  
        <input name="user_name" type=text value="<?php print($user_name);?>"></td>
    </tr>
    <tr>
      <td height="25" bgcolor="#CCCCCC" class="b"><strong>   เลขที่ส่งพัสดุ <span class="color"><span class="blue">(13 หลัก)</span></span> :</strong></td>
      <td height="25" bgcolor="#CCCCCC">  
        <input name="post_no" type=text value="<?php print($post_no);?>"></td>
    </tr>
    <tr>
      <td height="25" bgcolor="#EEEEEE" class="b"><strong>   วิธีการจัดส่งสินค้า :</strong></td>
      <td height="25" bgcolor="#EEEEEE">  
        <input type="radio" name="post_type" value="พัสดุธรรมดา">
        พัสดุธรรมดา
        <input type="radio" name="post_type" value="พัสดุลงทะเบียน">
        พัสดุลงทะเบียน
        <input type="radio" name="post_type" value="พัสดุ EMS">
        พัสดุ <span class="color">EMS</span></td>
    </tr>
    <tr>
      <td height="25" bgcolor="#CCCCCC" class="b"><strong>   วันจัดส่งสินค้า <span class="blue">(ปี-เดือน-วัน)</span> :</strong></td>
      <td height="25" bgcolor="#CCCCCC">  
        <input name="date" type=text id="date" value="<? print($date);?>"></td>
    </tr>
    <tr>
      <td height="25" bgcolor="#EEEEEE" class="b"><strong>   สถานะปัจจุบัน :</strong></td>
      <td height="25" bgcolor="#EEEEEE">  
        <input type="radio" name="status" value="รอโอน">
        รอโอน
        <input type="radio" name="status" value="รอส่ง">
        รอส่ง
        <input type="radio" name="status" value="ยกเลิก">
        ยกเลิก
        <input type="radio" name="status" value="คืนเงิน">
        คืนเงิน
        <input type="radio" name="status" value="ส่งแล้ว">
        ส่งแล้ว</td>
    </tr>
  </table>
  <p class="center"><br>
    <input type=submit value="บันทึกการแก้ไข">
     
    <INPUT TYPE="reset" VALUE="ลบพิมพ์ใหม่">
  </p>
  <a href="list_orders_admin.php" class="center"><span class="blue">ไปรายการสั่งซื้อ</span></a><span class="blue"> , <a href="addform.php">ไปบันทึกข้อมูล</a></span><br>
    <br>
  </p>
</form>
<p>
</p>
<p> </p>
<p> </p>
<p> </p>
<p class="center"> </p>
 edit_orders.php
 
 <style type="text/css">
.center {
	text-align: center;
}
#center {
	text-align: center;
}
</style>
<body class="center"><p> </p>
<p> </p>
<p> </p>
<p> </p>
<p> </p>
<p> </p>
<p> </p>
<p> </p>
<p> </p>
<table width="400" border="0" align="center" cellpadding="2" cellspacing="2">
  <tr>
    <td width="300" height="100" bgcolor="#EEEEEE" id="center"><?php echo "<b>แก้ไขข้อมูล</b><br>ใบสั่งซื้อเลขที่ <font color='blue'>$pay_no</font> ของคุณ <font color='red'>$user_name</font> เรียบร้อยแล้ว";?></td>
  </tr>
</table>
<p><a href="list_orders_admin.php">ไปรายการสั่งซื้อ</a> , <a href="addform.php">ไปบันทึกข้อมูล</a></p>
<p> </p>
<p> </p>
<p> </p>
<p> </p>
<p> </p>
<?php
include"db_setup.php"; //--->ไฟล์สำหรับเชื่อมต่อฐานข้อมูลที่นำเข้ามา
?>
<?php
//เลือกฐานข้อมูล
mysql_select_db($dbname) or die("เลือกฐานข้อมูลไม่ได้");
//ประกาศตัวแปร
$tb="list";//--->list คือชื่อตาราง
$sql="update $tb set status='$status',pay_no='$pay_no',user_name='$user_name',post_no='$post_no',post_type='$post_type',date='$date where no='$no";
$db_query=mysql_db_query($dbname,$sql);
echo "$sql";
echo "$no";
?>
 edit_form.php
 
 <?php
include"db_setup.php"; //--->ไฟล์สำหรับเชื่อมต่อฐานข้อมูลที่นำเข้ามา
?>
<?php
//เลือกฐานข้อมูล
mysql_select_db($dbname) or die("เลือกฐานข้อมูลไม่ได้");
//ประกาศตัวแปร
$tb="list";//--->list คือชื่อตาราง
$sql="select * from $tb where no=$no";
$dbquery=mysql_db_query($dbname,$sql);
$row=mysql_fetch_array($dbquery);
$no=$no;
$pay_no=$row['pay_no'];
$user_name=$row['user_name'];
$post_no=$row['post_no'];
#$post_type=$row['post_type'];
$date=$row['date'];
#$status=$row['status'];
mysql_close();
?>
<style type="text/css">
.b {	font-weight: bold;
}
.b {	font-weight: normal;
}
.blue {	color: #03C;
}
.color {	color: #F00;
}
.center form p {
	font-size: 16px;
	font-weight: bold;
	text-align: center;
}
.center form input {
	text-align: center;
}
center {
	text-align: center;
}
.center form {
	text-align: center;
}
</style>
<body class="center"><p> </p>
<p> </p>
<p> </p>
<p> </p>
<p> </p>
<form name="form1" method="post" action="edit_orders.php">
<!-- กำหนดไฟล์ที่รับข้อมูลจากฟอร์ม -->
  <p class="color"> </p>
  แก้ไขข้อมูล ลำดับที่ <font color=red><?php print($no);?></font><br>
  <br>
  <table width="750" border="0" align="center" cellpadding="1" cellspacing="1">
    <tr>
      <td width="350" height="25" bgcolor="#CCCCCC" class="b"30"><strong>    เลขที่ใบสั่งซื้อ<span class="color"> <span class="blue">(8 หลัก)</span></span> :</strong></td>
      <td width="350" height="25" bgcolor="#CCCCCC">  
        <input name="pay_no" type=text value="<?php print($pay_no);?>"></td>
        
    </tr>
    <tr>
      <td height="25" bgcolor="#EEEEEE" class="b"><strong>   ชื่อสมาชิก :</strong></td>
      <td height="25" bgcolor="#EEEEEE">  
        <input name="user_name" type=text value="<?php print($user_name);?>"></td>
    </tr>
    <tr>
      <td height="25" bgcolor="#CCCCCC" class="b"><strong>   เลขที่ส่งพัสดุ <span class="color"><span class="blue">(13 หลัก)</span></span> :</strong></td>
      <td height="25" bgcolor="#CCCCCC">  
        <input name="post_no" type=text value="<?php print($post_no);?>"></td>
    </tr>
    <tr>
      <td height="25" bgcolor="#EEEEEE" class="b"><strong>   วิธีการจัดส่งสินค้า :</strong></td>
      <td height="25" bgcolor="#EEEEEE">  
        <input type="radio" name="post_type" value="พัสดุธรรมดา">
        พัสดุธรรมดา
        <input type="radio" name="post_type" value="พัสดุลงทะเบียน">
        พัสดุลงทะเบียน
        <input type="radio" name="post_type" value="พัสดุ EMS">
        พัสดุ <span class="color">EMS</span></td>
    </tr>
    <tr>
      <td height="25" bgcolor="#CCCCCC" class="b"><strong>   วันจัดส่งสินค้า <span class="blue">(ปี-เดือน-วัน)</span> :</strong></td>
      <td height="25" bgcolor="#CCCCCC">  
        <input name="date" type=text id="date" value="<? print($date);?>"></td>
    </tr>
    <tr>
      <td height="25" bgcolor="#EEEEEE" class="b"><strong>   สถานะปัจจุบัน :</strong></td>
      <td height="25" bgcolor="#EEEEEE">  
        <input type="radio" name="status" value="รอโอน">
        รอโอน
        <input type="radio" name="status" value="รอส่ง">
        รอส่ง
        <input type="radio" name="status" value="ยกเลิก">
        ยกเลิก
        <input type="radio" name="status" value="คืนเงิน">
        คืนเงิน
        <input type="radio" name="status" value="ส่งแล้ว">
        ส่งแล้ว</td>
    </tr>
  </table>
  <p class="center"><br>
    <input type=submit value="บันทึกการแก้ไข">
     
    <INPUT TYPE="reset" VALUE="ลบพิมพ์ใหม่">
  </p>
  <a href="list_orders_admin.php" class="center"><span class="blue">ไปรายการสั่งซื้อ</span></a><span class="blue"> , <a href="addform.php">ไปบันทึกข้อมูล</a></span><br>
    <br>
  </p>
</form>
<p>
</p>
<p> </p>
<p> </p>
<p> </p>
<p class="center"> </p>
 |  
              | 
                
                  |  |  |  |  
                  |  | 
                      
                        | Date :
                            2011-08-01 16:34:54 | By :
                            อลันด์ |  |  |  
                  |  |  |  |  |  |  |  
          |  |  |  |  |  
 
        
          |  |  |  |  |  
          |  |  | 
            
              | ช่วยด้วยนะครับ เหลืออีกนิดเดียวจะเสร็จแล้วครับ ... 
 |  
              | 
                
                  |  |  |  |  
                  |  | 
                      
                        | Date :
                            2011-08-01 16:54:29 | By :
                            alundc45 |  |  |  
                  |  |  |  |  |  |  |  
          |  |  |  |  |  
 
        
          |  |  |  |  |  
          |  |  | 
            
              | <input type="hidden"  name="no" value="<?=$no?>" 
 
 ส่งค่า no ไปด้วย เอาไว้ ล่าง from ก็ได้
 
 |  
              | 
                
                  |  |  |  |  
                  |  | 
                      
                        | Date :
                            2011-08-01 17:00:58 | By :
                            teez1232002 |  |  |  
                  |  |  |  |  |  |  |  
          |  |  |  |  |  
 
        
          |  |  |  |  |  
          |  |  | 
            
              | ในหน้าที่แสดงรายการ(ดังภาพ) ให้แก้ไขโค้ด(ดังภาพนะ) เพื่อเป็นการส่งค่า $no ไปใช้เป็นเงื่อนไขในการแก้ไขข้อมูล 
 
  
 ส่วนหน้าแก้ไข คือ edit_orders.php
 Code (PHP)
 
 <?php
//เลือกฐานข้อมูล
mysql_select_db($dbname) or die("เลือกฐานข้อมูลไม่ได้");
//ประกาศตัวแปร
$tb="list";//--->list คือชื่อตาราง
$no = $_GET['no']; //เพิ่มบรรทัดนี้
$sql="update $tb set status='$status',pay_no='$pay_no',user_name='$user_name',post_no='$post_no',post_type='$post_type',date='$date where no='$no";
$db_query=mysql_db_query($dbname,$sql);
 ?>
 น่าจะได้แล้วนะผมว่า
 
 |  
              | 
                
                  |  |  |  |  
                  |  | 
                      
                        | Date :
                            2011-08-01 17:18:11 | By :
                            arm8957 |  |  |  
                  |  |  |  |  |  |  |  
          |  |  |  |  |  
 
        
          |  |  |  |  |  
          |  |  | 
            
              | ได้แล้วครับขอบคุณทุกท่านนะครับ .... 
 |  
              | 
                
                  |  |  |  |  
                  |  | 
                      
                        | Date :
                            2011-08-01 17:43:32 | By :
                            alundc45 |  |  |  
                  |  |  |  |  |  |  |  
          |  |  |  |  |  |  |