AssignmentTopic:    PHP UPDATE & DELETE OPERATIONSubmitted Date:              12-NOV-2012, MONDAY
Update Operation     <! DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0Transitional//EN""http://www.w3.org/TR/xhtml1/DTD/xhtml1...
{             $uid       =    $_REQUEST[user_id];             $user_name =         $_REQUEST[uname];             $email   ...
$res =   mysql_query($query);         $row     =   mysql_fetch_array($res);    ?>    <body>    <form>         username : <...
Delete Operation<! DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0Transitional//EN""http://www.w3.org/TR/xhtml1/DTD/xhtml1-tran...
}     if ($_REQUEST[uid]!="")     {            $uid =    $_REQUEST[uid];         $qry =       "DELETE FROM users WHEREuser...
<table border="1">    <tr>    <td>User ID</td><td>User Name</td><td>Email</td><td>Action</td></tr><?php           while($r...
<a href="?uid=<?php echo($rows[user_id]); ?>"onclick="return confirmation();" > Delete </a></td></tr><?php           }    ...
Upcoming SlideShare
Loading in …5
×

Php update and delet operation

4,018 views

Published on

For further information and help contact me : zoya.mehdi5@gmail.com

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

  • Be the first to like this

No Downloads
Views
Total views
4,018
On SlideShare
0
From Embeds
0
Number of Embeds
1
Actions
Shares
0
Downloads
5
Comments
0
Likes
0
Embeds 0
No embeds

No notes for slide

Php update and delet operation

  1. 1. AssignmentTopic: PHP UPDATE & DELETE OPERATIONSubmitted Date: 12-NOV-2012, MONDAY
  2. 2. Update Operation <! DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0Transitional//EN""http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="Content-Type" content="text/html;charset=utf-8" /> <title>Untitled Document</title> </head> <?php $uid = $_REQUEST[uid]; $con= mysql_connect("localhost","root",""); if($con) { mysql_select_db("bs_morning",$con); } if($_REQUEST[update]!="")
  3. 3. { $uid = $_REQUEST[user_id]; $user_name = $_REQUEST[uname]; $email = $_REQUEST[email]; $qry = "UPDATE users SETuser_name=$user_name ,user_email=$email WHEREuser_id=$uid"; $rs = mysql_query($qry); if(mysql_affected_rows() > 0) { echo("Data Updated !!!"); } else { echo("not updated !!! "); } } $query = "SELECT * FROM users WHEREuser_id=$uid";
  4. 4. $res = mysql_query($query); $row = mysql_fetch_array($res); ?> <body> <form> username : <input type="text" name="uname"value="<?php echo($row[user_name]); ?>" /> <br /> email : <input type="text" name="email" value="<?phpecho($row[user_email]); ?>" /> <br /> <input type="hidden" name="user_id" value="<?phpecho($uid); ?>" /> <input type="submit" name="update" value="UpdateRecord" /> </form> </body> </html>
  5. 5. Delete Operation<! DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0Transitional//EN""http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"><html xmlns="http://www.w3.org/1999/xhtml"><head><meta http-equiv="Content-Type" content="text/html;charset=utf-8" /><title>Untitled Document</title><?php $con= mysql_connect("localhost","root",""); if($con) { mysql_select_db("bs_morning",$con); } Else { echo("server details invalid");
  6. 6. } if ($_REQUEST[uid]!="") { $uid = $_REQUEST[uid]; $qry = "DELETE FROM users WHEREuser_id=$uid"; $rs = mysql_query($qry); } $query = "SELECT * FROM users"; $res = mysql_query($query);?><script type="text/javascript"> function confirmation() { return confirm("Are you Sure ??"); }</script></head><body>
  7. 7. <table border="1"> <tr> <td>User ID</td><td>User Name</td><td>Email</td><td>Action</td></tr><?php while($rows=mysql_fetch_array($res)) { ?> <tr> <td><?php echo($rows[user_id]) ?></td> <td><?php echo($rows[user_name]) ?></td> <td><?php echo($rows[user_email]) ?></td> <td> <a href="edit.php?uid=<?php echo($rows[user_id]); ?>">Edit</a>
  8. 8. <a href="?uid=<?php echo($rows[user_id]); ?>"onclick="return confirmation();" > Delete </a></td></tr><?php } ?></table></body></html>

×