SlideShare a Scribd company logo
1 of 8
Assignment

Topic:

    PHP UPDATE & DELETE OPERATION
Submitted Date:

              12-NOV-2012, MONDAY
Update Operation
     <! DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0
Transitional//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']!="")
{
             $uid       =    $_REQUEST['user_id'];
             $user_name =         $_REQUEST['uname'];
             $email          =    $_REQUEST['email'];
              $qry  =     "UPDATE users SET
user_name='$user_name' ,user_email='$email' WHERE
user_id='$uid'";
             $rs             =    mysql_query($qry);
             if(mysql_affected_rows() > 0)
             {
                    echo("Data Updated !!!");
             }
             else
             {
                    echo("not updated !!! ");
             }
         }
         $query     =   "SELECT * FROM users WHERE
user_id='$uid'";
$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="<?php
echo($row['user_email']); ?>" />
    <br />
    <input type="hidden" name="user_id" value="<?php
echo($uid); ?>" />
    <input type="submit" name="update" value="Update
Record" />
    </form>
    </body>
    </html>
Delete Operation
<! DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0
Transitional//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");
}
     if ($_REQUEST['uid']!="")
     {
            $uid =    $_REQUEST['uid'];
         $qry =       "DELETE FROM users WHERE
user_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>
<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>
<a href="?uid=<?php echo($rows['user_id']); ?>"
onclick="return confirmation();" > Delete </a>
</td>
</tr>
<?php


           }
    ?>
</table>
</body>
</html>

More Related Content

What's hot

Pemrograman Web 9 - Input Form DB dan Session
Pemrograman Web 9 - Input Form DB dan SessionPemrograman Web 9 - Input Form DB dan Session
Pemrograman Web 9 - Input Form DB dan SessionNur Fadli Utomo
 
与 PHP 和 Perl 使用 MySQL 数据库
与 PHP 和 Perl 使用 MySQL 数据库与 PHP 和 Perl 使用 MySQL 数据库
与 PHP 和 Perl 使用 MySQL 数据库YUCHENG HU
 
Zf Zend Db by aida
Zf Zend Db by aidaZf Zend Db by aida
Zf Zend Db by aidawaraiotoko
 
次世代版 PowerCMS 開発プロジェクトのご紹介
次世代版 PowerCMS 開発プロジェクトのご紹介次世代版 PowerCMS 開発プロジェクトのご紹介
次世代版 PowerCMS 開発プロジェクトのご紹介純生 野田
 
PHP Lecture 4 - Working with form, GET and Post Methods
PHP Lecture 4 - Working with form, GET and Post MethodsPHP Lecture 4 - Working with form, GET and Post Methods
PHP Lecture 4 - Working with form, GET and Post MethodsAl-Mamun Sarkar
 
Php redirect code
Php redirect codePhp redirect code
Php redirect codeVineet Garg
 
PHP Lecture 6 - Php file uploading
PHP Lecture 6 - Php file uploadingPHP Lecture 6 - Php file uploading
PHP Lecture 6 - Php file uploadingAl-Mamun Sarkar
 
PuppetCamp SEA 1 - Version Control with Puppet
PuppetCamp SEA 1 - Version Control with PuppetPuppetCamp SEA 1 - Version Control with Puppet
PuppetCamp SEA 1 - Version Control with PuppetWalter Heck
 
Ex[1].3 php db connectivity
Ex[1].3 php db connectivityEx[1].3 php db connectivity
Ex[1].3 php db connectivityMouli Chandira
 
Add edit delete in Codeigniter in PHP
Add edit delete in Codeigniter in PHPAdd edit delete in Codeigniter in PHP
Add edit delete in Codeigniter in PHPVineet Kumar Saini
 

What's hot (19)

Php (1)
Php (1)Php (1)
Php (1)
 
jQuery secrets
jQuery secretsjQuery secrets
jQuery secrets
 
Pemrograman Web 9 - Input Form DB dan Session
Pemrograman Web 9 - Input Form DB dan SessionPemrograman Web 9 - Input Form DB dan Session
Pemrograman Web 9 - Input Form DB dan Session
 
与 PHP 和 Perl 使用 MySQL 数据库
与 PHP 和 Perl 使用 MySQL 数据库与 PHP 和 Perl 使用 MySQL 数据库
与 PHP 和 Perl 使用 MySQL 数据库
 
Zf Zend Db by aida
Zf Zend Db by aidaZf Zend Db by aida
Zf Zend Db by aida
 
次世代版 PowerCMS 開発プロジェクトのご紹介
次世代版 PowerCMS 開発プロジェクトのご紹介次世代版 PowerCMS 開発プロジェクトのご紹介
次世代版 PowerCMS 開発プロジェクトのご紹介
 
PHP Lecture 4 - Working with form, GET and Post Methods
PHP Lecture 4 - Working with form, GET and Post MethodsPHP Lecture 4 - Working with form, GET and Post Methods
PHP Lecture 4 - Working with form, GET and Post Methods
 
Php redirect code
Php redirect codePhp redirect code
Php redirect code
 
PowerCMS X
PowerCMS XPowerCMS X
PowerCMS X
 
21. CodeIgniter search
21. CodeIgniter search21. CodeIgniter search
21. CodeIgniter search
 
jQuery's Secrets
jQuery's SecretsjQuery's Secrets
jQuery's Secrets
 
Borrados
BorradosBorrados
Borrados
 
Sql inyection
Sql inyectionSql inyection
Sql inyection
 
PHP Lecture 6 - Php file uploading
PHP Lecture 6 - Php file uploadingPHP Lecture 6 - Php file uploading
PHP Lecture 6 - Php file uploading
 
PuppetCamp SEA 1 - Version Control with Puppet
PuppetCamp SEA 1 - Version Control with PuppetPuppetCamp SEA 1 - Version Control with Puppet
PuppetCamp SEA 1 - Version Control with Puppet
 
PhoneGap: Local Storage
PhoneGap: Local StoragePhoneGap: Local Storage
PhoneGap: Local Storage
 
Ex[1].3 php db connectivity
Ex[1].3 php db connectivityEx[1].3 php db connectivity
Ex[1].3 php db connectivity
 
Add edit delete in Codeigniter in PHP
Add edit delete in Codeigniter in PHPAdd edit delete in Codeigniter in PHP
Add edit delete in Codeigniter in PHP
 
Pagination in PHP
Pagination in PHPPagination in PHP
Pagination in PHP
 

Similar to Php update and delet operation

Bag Of Tricks From Iusethis
Bag Of Tricks From IusethisBag Of Tricks From Iusethis
Bag Of Tricks From IusethisMarcus Ramberg
 
Command-Oriented Architecture
Command-Oriented ArchitectureCommand-Oriented Architecture
Command-Oriented ArchitectureLuiz Messias
 
Doctrine For Beginners
Doctrine For BeginnersDoctrine For Beginners
Doctrine For BeginnersJonathan Wage
 
Dependency Injection
Dependency InjectionDependency Injection
Dependency InjectionRifat Nabi
 
The History of PHPersistence
The History of PHPersistenceThe History of PHPersistence
The History of PHPersistenceHugo Hamon
 
Virtual Madness @ Etsy
Virtual Madness @ EtsyVirtual Madness @ Etsy
Virtual Madness @ EtsyNishan Subedi
 
The Zen of Lithium
The Zen of LithiumThe Zen of Lithium
The Zen of LithiumNate Abele
 
R57shell
R57shellR57shell
R57shellady36
 
DrupalCamp Foz - Novas APIs Drupal 7
DrupalCamp Foz - Novas APIs Drupal 7DrupalCamp Foz - Novas APIs Drupal 7
DrupalCamp Foz - Novas APIs Drupal 7chuvainc
 
Rich domain model with symfony 2.5 and doctrine 2.5
Rich domain model with symfony 2.5 and doctrine 2.5Rich domain model with symfony 2.5 and doctrine 2.5
Rich domain model with symfony 2.5 and doctrine 2.5Leonardo Proietti
 
The State of Lithium
The State of LithiumThe State of Lithium
The State of LithiumNate Abele
 
Drush. Secrets come out.
Drush. Secrets come out.Drush. Secrets come out.
Drush. Secrets come out.Alex S
 
Php code for online quiz
Php code for online quizPhp code for online quiz
Php code for online quizhnyb1002
 
laravel tricks in 50minutes
laravel tricks in 50minuteslaravel tricks in 50minutes
laravel tricks in 50minutesBarang CK
 

Similar to Php update and delet operation (20)

Bag Of Tricks From Iusethis
Bag Of Tricks From IusethisBag Of Tricks From Iusethis
Bag Of Tricks From Iusethis
 
Php
PhpPhp
Php
 
Command-Oriented Architecture
Command-Oriented ArchitectureCommand-Oriented Architecture
Command-Oriented Architecture
 
Doctrine For Beginners
Doctrine For BeginnersDoctrine For Beginners
Doctrine For Beginners
 
PHP || [Student Result Management System]
PHP || [Student Result Management System]PHP || [Student Result Management System]
PHP || [Student Result Management System]
 
Dependency Injection
Dependency InjectionDependency Injection
Dependency Injection
 
The History of PHPersistence
The History of PHPersistenceThe History of PHPersistence
The History of PHPersistence
 
Virtual Madness @ Etsy
Virtual Madness @ EtsyVirtual Madness @ Etsy
Virtual Madness @ Etsy
 
Php 101: PDO
Php 101: PDOPhp 101: PDO
Php 101: PDO
 
Daily notes
Daily notesDaily notes
Daily notes
 
The Zen of Lithium
The Zen of LithiumThe Zen of Lithium
The Zen of Lithium
 
PHP POWERPOINT SLIDES
PHP POWERPOINT SLIDESPHP POWERPOINT SLIDES
PHP POWERPOINT SLIDES
 
R57shell
R57shellR57shell
R57shell
 
DrupalCamp Foz - Novas APIs Drupal 7
DrupalCamp Foz - Novas APIs Drupal 7DrupalCamp Foz - Novas APIs Drupal 7
DrupalCamp Foz - Novas APIs Drupal 7
 
Laravel
LaravelLaravel
Laravel
 
Rich domain model with symfony 2.5 and doctrine 2.5
Rich domain model with symfony 2.5 and doctrine 2.5Rich domain model with symfony 2.5 and doctrine 2.5
Rich domain model with symfony 2.5 and doctrine 2.5
 
The State of Lithium
The State of LithiumThe State of Lithium
The State of Lithium
 
Drush. Secrets come out.
Drush. Secrets come out.Drush. Secrets come out.
Drush. Secrets come out.
 
Php code for online quiz
Php code for online quizPhp code for online quiz
Php code for online quiz
 
laravel tricks in 50minutes
laravel tricks in 50minuteslaravel tricks in 50minutes
laravel tricks in 50minutes
 

More from syeda zoya mehdi

Game playing in artificial intelligent technique
Game playing in artificial intelligent technique Game playing in artificial intelligent technique
Game playing in artificial intelligent technique syeda zoya mehdi
 
Maslow, herzberg, mc clelland, ouchi, thamhain and wilemon and convey theories
Maslow, herzberg, mc clelland, ouchi, thamhain and wilemon and convey theoriesMaslow, herzberg, mc clelland, ouchi, thamhain and wilemon and convey theories
Maslow, herzberg, mc clelland, ouchi, thamhain and wilemon and convey theoriessyeda zoya mehdi
 
Project quality management
Project quality managementProject quality management
Project quality managementsyeda zoya mehdi
 
Mobile phone calling and texting college students in pakistan
Mobile phone calling and texting college students in pakistanMobile phone calling and texting college students in pakistan
Mobile phone calling and texting college students in pakistansyeda zoya mehdi
 
Introduction of javascript
Introduction of javascriptIntroduction of javascript
Introduction of javascriptsyeda zoya mehdi
 

More from syeda zoya mehdi (10)

Sony nextep
Sony nextepSony nextep
Sony nextep
 
Android vs window
Android vs windowAndroid vs window
Android vs window
 
Game playing in artificial intelligent technique
Game playing in artificial intelligent technique Game playing in artificial intelligent technique
Game playing in artificial intelligent technique
 
Maslow, herzberg, mc clelland, ouchi, thamhain and wilemon and convey theories
Maslow, herzberg, mc clelland, ouchi, thamhain and wilemon and convey theoriesMaslow, herzberg, mc clelland, ouchi, thamhain and wilemon and convey theories
Maslow, herzberg, mc clelland, ouchi, thamhain and wilemon and convey theories
 
Project quality management
Project quality managementProject quality management
Project quality management
 
Mobile phone calling and texting college students in pakistan
Mobile phone calling and texting college students in pakistanMobile phone calling and texting college students in pakistan
Mobile phone calling and texting college students in pakistan
 
Table through php
Table through phpTable through php
Table through php
 
Firewall
FirewallFirewall
Firewall
 
Introduction of javascript
Introduction of javascriptIntroduction of javascript
Introduction of javascript
 
Windows phone
Windows phoneWindows phone
Windows phone
 

Recently uploaded

Install Stable Diffusion in windows machine
Install Stable Diffusion in windows machineInstall Stable Diffusion in windows machine
Install Stable Diffusion in windows machinePadma Pradeep
 
Kotlin Multiplatform & Compose Multiplatform - Starter kit for pragmatics
Kotlin Multiplatform & Compose Multiplatform - Starter kit for pragmaticsKotlin Multiplatform & Compose Multiplatform - Starter kit for pragmatics
Kotlin Multiplatform & Compose Multiplatform - Starter kit for pragmaticscarlostorres15106
 
Story boards and shot lists for my a level piece
Story boards and shot lists for my a level pieceStory boards and shot lists for my a level piece
Story boards and shot lists for my a level piececharlottematthew16
 
Advanced Test Driven-Development @ php[tek] 2024
Advanced Test Driven-Development @ php[tek] 2024Advanced Test Driven-Development @ php[tek] 2024
Advanced Test Driven-Development @ php[tek] 2024Scott Keck-Warren
 
"LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks...
"LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks..."LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks...
"LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks...Fwdays
 
SIP trunking in Janus @ Kamailio World 2024
SIP trunking in Janus @ Kamailio World 2024SIP trunking in Janus @ Kamailio World 2024
SIP trunking in Janus @ Kamailio World 2024Lorenzo Miniero
 
Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)
Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)
Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)Mark Simos
 
Are Multi-Cloud and Serverless Good or Bad?
Are Multi-Cloud and Serverless Good or Bad?Are Multi-Cloud and Serverless Good or Bad?
Are Multi-Cloud and Serverless Good or Bad?Mattias Andersson
 
My Hashitalk Indonesia April 2024 Presentation
My Hashitalk Indonesia April 2024 PresentationMy Hashitalk Indonesia April 2024 Presentation
My Hashitalk Indonesia April 2024 PresentationRidwan Fadjar
 
SAP Build Work Zone - Overview L2-L3.pptx
SAP Build Work Zone - Overview L2-L3.pptxSAP Build Work Zone - Overview L2-L3.pptx
SAP Build Work Zone - Overview L2-L3.pptxNavinnSomaal
 
DevEX - reference for building teams, processes, and platforms
DevEX - reference for building teams, processes, and platformsDevEX - reference for building teams, processes, and platforms
DevEX - reference for building teams, processes, and platformsSergiu Bodiu
 
Gen AI in Business - Global Trends Report 2024.pdf
Gen AI in Business - Global Trends Report 2024.pdfGen AI in Business - Global Trends Report 2024.pdf
Gen AI in Business - Global Trends Report 2024.pdfAddepto
 
New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024BookNet Canada
 
Understanding the Laravel MVC Architecture
Understanding the Laravel MVC ArchitectureUnderstanding the Laravel MVC Architecture
Understanding the Laravel MVC ArchitecturePixlogix Infotech
 
Artificial intelligence in cctv survelliance.pptx
Artificial intelligence in cctv survelliance.pptxArtificial intelligence in cctv survelliance.pptx
Artificial intelligence in cctv survelliance.pptxhariprasad279825
 
Dev Dives: Streamline document processing with UiPath Studio Web
Dev Dives: Streamline document processing with UiPath Studio WebDev Dives: Streamline document processing with UiPath Studio Web
Dev Dives: Streamline document processing with UiPath Studio WebUiPathCommunity
 
AI as an Interface for Commercial Buildings
AI as an Interface for Commercial BuildingsAI as an Interface for Commercial Buildings
AI as an Interface for Commercial BuildingsMemoori
 

Recently uploaded (20)

Install Stable Diffusion in windows machine
Install Stable Diffusion in windows machineInstall Stable Diffusion in windows machine
Install Stable Diffusion in windows machine
 
Kotlin Multiplatform & Compose Multiplatform - Starter kit for pragmatics
Kotlin Multiplatform & Compose Multiplatform - Starter kit for pragmaticsKotlin Multiplatform & Compose Multiplatform - Starter kit for pragmatics
Kotlin Multiplatform & Compose Multiplatform - Starter kit for pragmatics
 
Story boards and shot lists for my a level piece
Story boards and shot lists for my a level pieceStory boards and shot lists for my a level piece
Story boards and shot lists for my a level piece
 
Advanced Test Driven-Development @ php[tek] 2024
Advanced Test Driven-Development @ php[tek] 2024Advanced Test Driven-Development @ php[tek] 2024
Advanced Test Driven-Development @ php[tek] 2024
 
"LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks...
"LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks..."LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks...
"LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks...
 
SIP trunking in Janus @ Kamailio World 2024
SIP trunking in Janus @ Kamailio World 2024SIP trunking in Janus @ Kamailio World 2024
SIP trunking in Janus @ Kamailio World 2024
 
Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)
Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)
Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)
 
Are Multi-Cloud and Serverless Good or Bad?
Are Multi-Cloud and Serverless Good or Bad?Are Multi-Cloud and Serverless Good or Bad?
Are Multi-Cloud and Serverless Good or Bad?
 
E-Vehicle_Hacking_by_Parul Sharma_null_owasp.pptx
E-Vehicle_Hacking_by_Parul Sharma_null_owasp.pptxE-Vehicle_Hacking_by_Parul Sharma_null_owasp.pptx
E-Vehicle_Hacking_by_Parul Sharma_null_owasp.pptx
 
My Hashitalk Indonesia April 2024 Presentation
My Hashitalk Indonesia April 2024 PresentationMy Hashitalk Indonesia April 2024 Presentation
My Hashitalk Indonesia April 2024 Presentation
 
SAP Build Work Zone - Overview L2-L3.pptx
SAP Build Work Zone - Overview L2-L3.pptxSAP Build Work Zone - Overview L2-L3.pptx
SAP Build Work Zone - Overview L2-L3.pptx
 
DevEX - reference for building teams, processes, and platforms
DevEX - reference for building teams, processes, and platformsDevEX - reference for building teams, processes, and platforms
DevEX - reference for building teams, processes, and platforms
 
Gen AI in Business - Global Trends Report 2024.pdf
Gen AI in Business - Global Trends Report 2024.pdfGen AI in Business - Global Trends Report 2024.pdf
Gen AI in Business - Global Trends Report 2024.pdf
 
New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
 
Hot Sexy call girls in Panjabi Bagh 🔝 9953056974 🔝 Delhi escort Service
Hot Sexy call girls in Panjabi Bagh 🔝 9953056974 🔝 Delhi escort ServiceHot Sexy call girls in Panjabi Bagh 🔝 9953056974 🔝 Delhi escort Service
Hot Sexy call girls in Panjabi Bagh 🔝 9953056974 🔝 Delhi escort Service
 
Understanding the Laravel MVC Architecture
Understanding the Laravel MVC ArchitectureUnderstanding the Laravel MVC Architecture
Understanding the Laravel MVC Architecture
 
Artificial intelligence in cctv survelliance.pptx
Artificial intelligence in cctv survelliance.pptxArtificial intelligence in cctv survelliance.pptx
Artificial intelligence in cctv survelliance.pptx
 
DMCC Future of Trade Web3 - Special Edition
DMCC Future of Trade Web3 - Special EditionDMCC Future of Trade Web3 - Special Edition
DMCC Future of Trade Web3 - Special Edition
 
Dev Dives: Streamline document processing with UiPath Studio Web
Dev Dives: Streamline document processing with UiPath Studio WebDev Dives: Streamline document processing with UiPath Studio Web
Dev Dives: Streamline document processing with UiPath Studio Web
 
AI as an Interface for Commercial Buildings
AI as an Interface for Commercial BuildingsAI as an Interface for Commercial Buildings
AI as an Interface for Commercial Buildings
 

Php update and delet operation

  • 1. Assignment Topic: PHP UPDATE & DELETE OPERATION Submitted Date: 12-NOV-2012, MONDAY
  • 2. Update Operation <! DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//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. { $uid = $_REQUEST['user_id']; $user_name = $_REQUEST['uname']; $email = $_REQUEST['email']; $qry = "UPDATE users SET user_name='$user_name' ,user_email='$email' WHERE user_id='$uid'"; $rs = mysql_query($qry); if(mysql_affected_rows() > 0) { echo("Data Updated !!!"); } else { echo("not updated !!! "); } } $query = "SELECT * FROM users WHERE user_id='$uid'";
  • 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="<?php echo($row['user_email']); ?>" /> <br /> <input type="hidden" name="user_id" value="<?php echo($uid); ?>" /> <input type="submit" name="update" value="Update Record" /> </form> </body> </html>
  • 5. Delete Operation <! DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//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. } if ($_REQUEST['uid']!="") { $uid = $_REQUEST['uid']; $qry = "DELETE FROM users WHERE user_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. <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. <a href="?uid=<?php echo($rows['user_id']); ?>" onclick="return confirmation();" > Delete </a> </td> </tr> <?php } ?> </table> </body> </html>