• Save
07 Php Mysql Update Delete
Upcoming SlideShare
Loading in...5
×
 

Like this? Share it with your network

Share

07 Php Mysql Update Delete

on

  • 6,629 views

PHP MYSQL update and delete.

PHP MYSQL update and delete.

Statistics

Views

Total Views
6,629
Views on SlideShare
6,619
Embed Views
10

Actions

Likes
2
Downloads
0
Comments
2

3 Embeds 10

http://www.slideshare.net 8
http://localhost 1
http://translate.googleusercontent.com 1

Accessibility

Categories

Upload Details

Uploaded via as Microsoft PowerPoint

Usage Rights

© All Rights Reserved

Report content

Flagged as inappropriate Flag as inappropriate
Flag as inappropriate

Select your reason for flagging this presentation as inappropriate.

Cancel
  • Full Name Full Name Comment goes here.
    Are you sure you want to
    Your message goes here
    Processing…
  • You can download the code and the slides here: http://www.geshanmanandhar.com/slides/php?page=2
    Are you sure you want to
    Your message goes here
    Processing…
  • please can i get chance to download this slide for taking knowledgee?
    Are you sure you want to
    Your message goes here
    Processing…
Post Comment
Edit your comment

07 Php Mysql Update Delete Presentation Transcript

  • 1. PHP Day 07 Geshan Manandhar Developer, Young Innovations Private Limited www.geshanmanandhar.com http://www.php.net http://www.mysql.com
  • 2. List Users with actions (detail, edit, delete)
  • 3. How to code the actions column
    • Inside while ($row= mysql_fetch_array($user_records) loop
      • $user_id = $row['user_id'];
    • $user_table .= &quot;<td>&quot;; //line no. 56 – day07show_users_with_actions.php
    • $user_table .= &quot;<a href=&quot;user_detail.php?id=$user_id&quot;>Detail</a> - &quot;;
    • $user_table .= &quot;<a href=&quot;user_edit.php?id=$user_id&quot;>Edit</a> - &quot;;
    • $user_table .= &quot;<a href=&quot;user_delete.php?id=$user_id&quot;&quot;;
    • $user_table .= ' onclick=&quot;javascript:return confirm('Do you really want to delete?');&quot;';
    • $user_table .= &quot;>Delete</a> - &quot;;
    • $user_table .= &quot;</td> &quot;;
  • 4. User Detail
  • 5. Show user table construction code
  • 6. Output of user_detail.php?id=X
  • 7. Update User.
    • Form is a combination of prog46_user_reg.php and user_detail.php.
    • user_edit.php is a form with values of the user_id passed via the URL.
    • Check out the code at day07user_edit.php
    • It also needs a variable called id to be passed vai the URL making the URL look something like: http://localhost/php_class/day07/user_edit.php?id=5
  • 8. Output of User Update form
  • 9. Edit user the function
  • 10. Delete User
    • In every delete call always confirm the delete operation, preferably with javascript.
    • Similar to user_detail but this operation deletes the record from the database.
    • Usage of parameter via URL and fetched in $_GET variable.
    • Full code at: day07user_delete.php
  • 11. Delete user function code
  • 12. CRUD done
    • That sums up the regular Create Read Update Delete (CRUD) operations.
    • The common and most used operation in any database focused application.
    • Other things like search, sorting etc are enhanced form or Read/Retrieve.
    • Things to do: some sorting and join queries for tables.
  • 13. Questions
  • 14. Assignment
    • Create a user management system with picture upload, the database only stores the filename. (keep in mind file should not be over-written in case of same filename).
    • Let there be option for type of user “Admin”, “Super User” or “Normal User”.
    • Perform CRUD operations on your login system.