SitePoint Sponsor

User Tag List

Results 1 to 2 of 2

Thread: quanity update

  1. #1
    SitePoint Addict
    Join Date
    Oct 2010
    Posts
    292
    Mentioned
    2 Post(s)
    Tagged
    0 Thread(s)

    quanity update

    please i am trying to make an update in a database where changes have been made to quantity,but i need a guide where the change is update is only made to where the change is done.

    this is the code where the changes would be done

    PHP Code:


        <?
        $pplresult 
    mysql_query("SELECT * FROM repplac");
        echo 
    "<table border='1'><tr><th> SHOP NAME</th><th> PRODUCT NAME</th><th>
        PRODUCT SIZE</th><th> PRODUCT COLOUR</th><th> PRODUCT QUANTITY</th><th>
        PRICE</th><th> </th></tr>"
    ;
        while(
    $row mysql_fetch_assoc($pplresult)){?>
        <form action='updatepplac.php' method='Post' class='slistbar'>
        <?echo "<tr><td>" .$row['Sname'] ."</td><td>" .$row['Pname'] ."</td><td>" .$row['Psize'] ."</td><td>" .$row['Pcolour'] ."</td><td>" ."<input type='text' name='Pquantity' id='Pquantity' value='{$row['Pquantity']}' >" ."</td><td>" .$row['Price'] ."</td><td>" ?>
        <a href="deleteproduct.php?del=<?php echo $row['Pidno'];?>">delete</a></td></tr><?php }
        
    // table closing tag
        
    ?>
    and the update script

    PHP Code:


        $submit 
    $_POST['submit'];
                
    $pid $_GET['del'];
                
    $nPquantity $_POST['Pquantity'];
                
    //echo "$nPquantity";
                
                //die();
                
    if('POST' === $_SERVER['REQUEST_METHOD'])
                {
                
    $queryreg mysql_query("
                UPDATE repplac SET Pquantity='
    $nPquantity' ")or die(mysql_error());
                } 
    i KNOW I HAVE NOT SPECIFIED WHERE THE UPDATE IS TO BE DONE, WHEN I ECHOED THE QUANTITY CHANGE, IT ONLY CAME BACK, WITH RESULT WHERE THE LAST ROW WAS CHANGED AND NOT ALL WHERE CHANGES WHERE DONE, AND I DID NOT KNOW THE FUNCTION TO BRING THE POST VARIABLE BCK IN ARRAY TO CHECK THE VARIABLE RETURNED, PLEASE I NEED A GUIDE THANKS ON HOW TO MAKE UPDATE CHANGES AT THE RIGHT PLACES.THANKS

  2. #2
    SitePoint Enthusiast
    Join Date
    Aug 2011
    Posts
    67
    Mentioned
    1 Post(s)
    Tagged
    0 Thread(s)
    shouldn't there be a WHERE in that UPDATE query somewhere?

    PHP Code:
    mysql_query("UPDATE repplac SET Pquantity='$nPquantity' WHERE your_id_column = '$pid'")or die(mysql_error()); 


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •