postheadericon PHP-Delete Record using prepared statement in PDO

Part-7: Delete Record using prepared statement in PDO.



In the last and part number seven, explain how to delete record using prepared statement. To keep delete operation simple I have not added any prompting for the confirmation of record deletion from user side.  This can be done by little bit JavaScript coding.

To delete a record first we have to select that which record we want to delete from MySQL table. Like our previous update operation we again utilize the result of search or display operation where a like delete is there to do the delete operation. When user click on that delete link the id of record is pass as a GET request to delete.php file where the actual delete statement execute of database and delete operation performed using prepared statement.

postheadericon PHP - Update Record using prepared statement in PDO

Part-6: Update Record using prepared statement in PDO


I part six, we do the update operation. To do the update we need to select a record which user want to update. From search or display operation that we discuss in previous part user click on edit link and select record for edit. When user select or click on edit link it will pass the id field in GET request to our edit.php file. With the help of record id we retrieve the entire record from table and fill it in to a HTML form where user can do the update operation. After updating information in HTML form user submit the update value by Update button. It pass all the information to our update.php file where the actual update SQL query execute on MySQL table and update the record using prepared statement of PDO. 

postheadericon PHP - Search records using AJAX and PDO



Part-5: Search records using AJAX and PDO in PHP



In part five, we do the search operation on our MySQL table. We use prepared statement to execute our query using PHP-PDO object. In SQL query we use like operator so it match record like the input we get from search.html file. To do the search object we use the AJAX technology to pass the request to search.php file. The file search.php is exactly similar to display.php file, just a where condition is added to do the search operation.  If we do the smart work then one file display.php or search.php is enough to do both operation just an if condition is required that check the request parameter whether search criteria is provided or not? To keep it simple I have use to separate file that would be helpful to beginners.

postheadericon Part-4: Display Records using prepared statement



Part-4: Display Records using prepared statement.



In part four, we concentrate on fetching record from database using prepared statement. We use select SQL statement to retrieve all record from table. After executing our query using PDO object we check whether it return the rows or not. If it does not return records then “No record found.” Message will be shown otherwise record will be display in HTML table. Last two column have link for Edit and Update record. When user click on it, it pass id to edit or delete page using default GET method. 


postheadericon PHP insert update, delete using PDO part-3


Part-3: Insert record using prepared statement in PDO.


In part three, I am creating two file one is the HTML file (insert.html) to define form to get the information and second one (insert.php) is the code behind file to retrieve the values from HTML and insert those values in database using prepared statement with the help of PDO.

Total Pageviews

© BipinRupadiya.com. Powered by Blogger.