Your SlideShare is downloading. ×
0
Web app development_crud_13
Web app development_crud_13
Web app development_crud_13
Web app development_crud_13
Web app development_crud_13
Web app development_crud_13
Web app development_crud_13
Web app development_crud_13
Web app development_crud_13
Web app development_crud_13
Web app development_crud_13
Web app development_crud_13
Web app development_crud_13
Upcoming SlideShare
Loading in...5
×

Thanks for flagging this SlideShare!

Oops! An error has occurred.

×
Saving this for later? Get the SlideShare app to save on your phone or tablet. Read anywhere, anytime – even offline.
Text the download link to your phone
Standard text messaging rates apply

Web app development_crud_13

407

Published on

Published in: Technology
0 Comments
1 Like
Statistics
Notes
  • Be the first to comment

No Downloads
Views
Total Views
407
On Slideshare
0
From Embeds
0
Number of Embeds
0
Actions
Shares
0
Downloads
25
Comments
0
Likes
1
Embeds 0
No embeds

Report content
Flagged as inappropriate Flag as inappropriate
Flag as inappropriate

Select your reason for flagging this presentation as inappropriate.

Cancel
No notes for slide

Transcript

  • 1. hasen@microcis.net July 23, 2013Hassen poreya Trainer, Cresco Solution Afghanistan Workforce Development Program CRUD Create, Read, Update, Delete
  • 2. Requirements  Choice of DBMS - MySQL  Database model (ER - Schema)  GUI – Application program
  • 3. Functions may be used in CRUD  mysql_connect()  mysql_select_db()  include()  mysql_query()  mysql_fetch_array()  mysql_num_rows()
  • 4. mysql_connect()  mysql_connect()is designed to handle the connection.  You can use this function internally or you can include it from an external source.  This function takes 3 arguments by default.  host, username, password mysql_connect("localhost","admin", “admin");
  • 5. mysql_connect()  To check whether the connection is established or not we store this function into a variable and check it with IF statement. <?php $con=mysql_connect("localhost","admin","admin"); if(!$con){ die('Could not connect: ' . mysql_error()); } ?>  You can use this piece of code anywhere in your code anytime, but that’s might be used several times. Then you can put your code in a separate file
  • 6. mysql_connect() In a Separated File  You code up your connection and db selection into a separate file, then you include that file into the main file. Ex: connect.php contains the connection. <?php .... include („connect.php‟); .... ?>
  • 7. mysqlSelect_db()  Once you have successfully connected to My SQL, then you must chose a database to work on.  Another PHP fucnction is used to select a database from database server. mysql_select_db(“users”);
  • 8. Query Conversion  We have SELECT and INSERT queries in Mysql and simply use them during inserting and retrieving. BUT if we want to use them with PHP we must convert them into PHP code.  This conversion is done by a built-in PHP function called mysql_query() mysql_query ("INSERT INTO users (username, password) VALUES ('$uname', '$pword')")
  • 9. Query Conversion mysql_query("SELECT * FROM users WHERE username= „ahmad'");  When we use SELECT statement, each time it returns one row of a table.  To store the returned data into a variable we must fetch them one by one and store them.  This can be done by a function called  mysql_fetch_array()
  • 10. Query Conversion $query=mysql_query("SELECT * FROM users WHERE username= „ahmad'");  $result= mysql_fetch_array($query) QueryFetch row by row from queryRecord set
  • 11. mysql_num_rows()  The mysql_num_rows() function returns the number of rows in a record set.  This function returns FALSE on failure.
  • 12. Let’s do the practice
  • 13. hasen@microcis.net July 23, 2013Hassen poreya Trainer, Cresco Solution Any Questions! Afghanistan Workforce Development Program

×