How to insert, delete, update and fetch record in the database using PHP coding at same page with database connection.
Record insert, delete fetch and update through PHP coding with database connection at
Collapse
X
-
Tags: None
-
-
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
Next, you should look for an action in the $_POST (update/delete)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>
This is for example the form that should be show when getting an action=update from the GET (read above)
And of course, when detecting something from the $_POST, you should save it to the database...Code:<form action="index.php?action=update" method="post" name="form1" id="form1"> <input type="hidden" name="action" value="update"> ... </form>
Hope that this helps....Code:if ((isset($_POST["action"])) && ($_POST["action"] == "update")) { $updateSQL = "UPDATE .................... }Comment
Comment