hello

Wednesday, September 24, 2014

3.4 Delete

1) Connection

       
//Connection variables -->START

$host = 'localhost';    /*domain name or host path*/
$user = 'root';         /*database username*/
$pass = 'your_db_pass'; /*database password*/ 
$database = 'db_users';    /*database name*/

//Connection variables-->END
  

2) Connection to Database

       
/*Create a connection to database*/
$connection = mysql_connect($host, $user, $pass) or die('Connection Failed');

/*Selecting the database based on suplied connection*/
$select_db = mysql_select_db($database, $connection) or die('Connection DB Failed');
  


3)The Query

/*Make a Query DELETE*/
$query = "delete from  users_tbl where username='hac101'";


4) Full Code

       
//Connection variables -->START

$host = 'localhost';    /*domain name or host path*/
$user = 'root';         /*database username*/
$pass = 'your_db_pass'; /*database password*/ 
$database = 'db_users';    /*database name*/

//Connection variables-->END

/*Create a connection to database*/
$connection = mysql_connect($host, $user, $pass) or die('Connection Failed');

/*Selecting the database based on suplied connection*/
$select_db = mysql_select_db($database, $connection) or die('Connection DB Failed');

/*Make a Query DELETE*/
$query = "delete from  users_tbl where username='hac101'";

/*Run the Query*/
$result = mysql_query($query) or die("Query Failed");

No comments: