<?php
echo "<form action='' method=\"post\">";
echo "<table border='1'>
    <tr class='' >   
    <th> P.Name </th>
    <th> P.Size </th>
    <th> P.Quantity </th>
    <th> P.Price </th>
    <th> P.Delete </th>
    </tr>";
    $query ="SELECT * FROM `order_detail` WHERE `orderID` = $viewID ";
    $result=mysqli_query($connection,$query);
    while($row=mysqli_fetch_array($result,MYSQL_ASSOC)){

        $Id=$row['ID'];
      echo "<tr>";

      echo "<td> <input type=\"text\"  name=product_name value=\"$row[prodName]\"> </td>";
      echo "<td> <input type=\"text\"  name=product_size value=$row[prodSize]> </td>";
      echo "<td> <input type=\"text\"  name=product_qty value=$row[prodQty]>  </td>";
      echo "<td> <input type=\"text\"  name=product_price value=$row[prodPrice]></td>";
      $query_sting = "Id={$row['ID']}&veiw=$viewID";
      $delete_page = "order_delete.php?". $query_sting;
      echo "<td><a href='$delete_page' onclick=\"return confirm('Are you sure?');\"><img src='images/DELETE.png'></a></td>";
      echo "</tr>";
      }
    echo "</table>";
    echo "</form>";
    if(isset($_POST['hitler'])){
        $sql ="UPDATE order_detail SET ";
      $sql .="prodName = '$product_name', ";
      $sql .="prodSize = '$size', ";
      $sql .="prodQty  = '$product_qty',";
      $sql .="prodPrice = '$product_amount' ";
      $sql .="WHERE `ID` ='$Id' ";
      $result = mysqli_query($connection,$sql);}

?>

thnx in advance
want to update mutiple record
this code is updated the last record only

In order to perform multiple updates you have to submit the fields of the form as array groups, for example:

<form action="" method="post">
<table>
    <thead>
        <tr>
            <th>ID</th>
            <th>Name</th>
            <th>Size</th>
            <th>Qty</th>
            <th>Price</th>
        </tr>

    <tbody>
        <tr>
            <!-- group 0 -->
            <td><input type="text" readonly name="product[0][id]" value="23" /></td>
            <td><input type="text" name="product[0][name]" /></td>
            <td><input type="text" name="product[0][size]" /></td>
            <td><input type="text" name="product[0][qty]" /></td>
            <td><input type="text" name="product[0][price]" /></td>
        </tr>
        <tr>
            <!-- group 1 -->
            <td><input type="text" readonly name="product[1][id]" value="72" /></td>
            <td><input type="text" name="product[1][name]" /></td>
            <td><input type="text" name="product[1][size]" /></td>
            <td><input type="text" name="product[1][qty]" /></td>
            <td><input type="text" name="product[1][price]" /></td>
        </tr>
</table>

    <input type="submit" name="button" value="update" />
</form>

When you print the $_POST array you get:

Array
(
    [product] => Array
        (
            [0] => Array
                (
                    [id] => 23
                    [name] => Apples
                    [size] => 1
                    [qty] => 10
                    [price] => 6
                )

            [1] => Array
                (
                    [id] => 72
                    [name] => Oranges
                    [size] => 2
                    [qty] => 17
                    [price] => 8.90
                )

        )

    [button] => update
)

At this point you can loop $_POST['product'] to update each product separatedly:

foreach($_POST['product'] as $product)
{
    echo $product['id'] . $product['name'] . '... and so on';
}

Best would be to use prepared statements so you can create the update query and then just loop the execution with the parameters.

NOT UNDERSTANT IT

What you don't understand?

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.