php mysql updating a field in db

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • impin
    New Member
    • Jul 2010
    • 127

    php mysql updating a field in db

    i displayed list of records from my product table.
    such as pid, pname,price,qty ,availability with a edit link for a each row...

    if i click the edit link it will update availablity filed.
    i dont want to enter the pid in the form. it will automatically detect the pid and update the particular record.

    if i click the 1sr row edit link it will update the first row record, similary for 2nd row 2nd row/s edit link.. etc....
  • TheServant
    Recognized Expert Top Contributor
    • Feb 2008
    • 1168

    #2
    Welcome to Bytes. I cannot see your question? Have you started with any code? We can help you with code you have, but do not write scripts for most people.

    Comment

    • impin
      New Member
      • Jul 2010
      • 127

      #3
      ya. i displayed records from db.

      pid pname qty price
      090 nerewr 4 4546 edit[link]
      888 sdgsd 5 8909 edit[link]

      if i click the edit link of 1st row i want to change the qty of the 1st record that is pid=090.

      if i go to the edit.php file where i can give input as qty="some value" and click submit it should update the first row.

      if i click the edit link of 2nd row i want to change the qty of the 2nd record that is pid=888.

      if i go to the edit.php file where i can give input as qty="some value" and click submit it should update the 2nd row.

      Code:
      <td> <?php echo $row["pid"]; ?></td>
                   <td><?php echo $row["pname"]; ?></td>
                   <td><?php echo $row["qty"]; ?></td>
                   <td><?php echo $row["price"]; ?></td>
                   <td>
      			 </td><td>
                 <?php 
      		   echo ( '<img src="edit.ico" /><a href="edit.php?pid=".$pid."\">Edit</a>');*/?>
      Last edited by Dormilich; Jul 28 '10, 05:31 PM. Reason: Please use [code] tags when posting code

      Comment

      • TheServant
        Recognized Expert Top Contributor
        • Feb 2008
        • 1168

        #4
        I still don't understand. The code you posted has no <input /> tags?

        Have you got any experience with submitting a form? Getting form data from $_POST? Updating MySQL table? Where ever your edit form is, make it submit to the page containing the data you have above (with the action parameter of the <form> tag). At the top of this page, you will need to collect the submitted data using something like:
        Code:
        $pname = $_POST['pname'];
        $qty = $_POST['qty'];
        $price = $_POST['price'];
        With some data verification etc... And then update the MySQL table with those variables, before you collect the data again to display in the table below.

        Comment

        Working...