Showing posts with label PHP with MySql database. Show all posts
Showing posts with label PHP with MySql database. Show all posts

Wednesday, February 22, 2012

Delete data from MySql Database


This program will delete data from MySql server Database. Change the database name and table name according to your system setting.

Before delete operation:-




After Delete operation:-
 
<?php
$conn=mysql_connect("localhost","root","");
if($conn==NULL)
 echo "Database connection failure";
$db=mysql_select_db("asp",$conn);
if($db==NULL)
   echo "Database selection failure";
$qur="delete from login where username='aaa'";
mysql_query($qur);
?>

Insert data into MySql using PHP


Insert data into Mysql Database using PHP.

This program is for insert data into database. Copy and paste it and do necessary change according to your database setting. 

Before Insert operation:-
After Insert operation:-

 




<?php
$conn=mysql_connect("localhost","root","");
if($conn==NULL)
 echo "Database connection failure";
$db=mysql_select_db("asp",$conn);
if($db==NULL)
 echo "Database selection failure";
$qur="insert into login values('aaa','aaa')";
mysql_query($qur);
?>

Show data from Mysql using PHP


This program is for connect PHP with Mysql Database . Just copy and paste following code and edit according to your database connection.
My database information is like this
Database:-localhost
Username:-root
Password:-
Tablename:-login




<?php
$conn=mysql_connect("localhost","root","");
if($conn==NULL)
 echo "Database connection failure";
$db=mysql_select_db("asp",$conn);
if($db==NULL)
 echo "Database selection failure";
$qur="select * from login";
$result=mysql_query($qur);
while($row=mysql_fetch_array($result))
{
  echo $row['username'];
  echo "<br>";
  echo $row['password'];
}
?>