Record insert, delete fetch and update through PHP coding with database connection at

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • sneha billore
    New Member
    • Sep 2012
    • 1

    #1

    Record insert, delete fetch and update through PHP coding with database connection at

    How to insert, delete, update and fetch record in the database using PHP coding at same page with database connection.
  • johny10151981
    Top Contributor
    • Jan 2010
    • 1059

    #2
    You want people to write a book for you? better yet buy a book and start reading

    Comment

    • ayukawaa
      New Member
      • Sep 2012
      • 9

      #3
      Use at the same time actions readed from the GET and POST.

      First, look for the action in the $_GET (insert/update/delete) and show the form based in the action given (see below).

      If the action does not exist, show a table with the LIST of the records from the database.

      In each row, add the actions like this

      Code:
      <a href="index.php?action=update&id=<?php echo $row_id;?>">UPDATE</a> 
      <a href="index.php?action=delete&id=<?php echo $row_id;?>">DELETE</a>
      Next, you should look for an action in the $_POST (update/delete)

      This is for example the form that should be show when getting an action=update from the GET (read above)

      Code:
      <form action="index.php?action=update" method="post" name="form1" id="form1">
      <input type="hidden" name="action" value="update">
      ...
      </form>
      And of course, when detecting something from the $_POST, you should save it to the database...

      Code:
      if ((isset($_POST["action"])) && ($_POST["action"] == "update")) {
        $updateSQL = "UPDATE ....................
      }
      Hope that this helps....

      Comment

      Working...