Unit-6-Connectivity With PHP and MYSQL
Unit-6-Connectivity With PHP and MYSQL
if($conn)
{
echo "connection established successfully..." ;
}
else
{
die("connection failed...");
}
?>
if($conn)
{
echo "connection established successfully..." ;
$qry="create database tt";
$ans=mysqli_query($conn,$qry);
if($ans)
{
echo "database created successfully..." ;
}
}
else
{
die("error...");
}
?>
if($conn)
{
echo "connection established successfully..." ;
$qry="create table t1(no int Primary Key, name varchar(30),city varchar(30))";
$ans=mysqli_query($conn,$qry);
if($ans)
{
echo "Table created successfully..." ;
}
if($conn)
{
$qry="insert into t1 values(1,'Trupti','Surat')";
$ans=mysqli_query($conn,$qry);
if($ans)
{
echo "Record inserted successfully..." ;
}
}
else
{
die("error...");
}
?>
if($conn)
{
$qry="update t1 set name='Devi' where no=2";
$ans=mysqli_query($conn,$qry);
if($ans)
{
echo "Record updated successfully..." ;
}
}
else
{
die("error...");
}
?>
Before updated:
if($conn)
{
$qry="delete from t1 where no=3";
$ans=mysqli_query($conn,$qry);
if($ans)
{
echo "Record deleted successfully..." ;
}
}
else
{
die("error...");
}
?>
$conn=mysqli_connect('localhost:3307','root',' ');
mysqli_select_db($conn,'tt');
mysqli_query($conn,$qry);
mysqli_close($conn);
if($conn)
{
echo "Record inserted successfully….";
}
else{
die('error....');
}
?>
<?php
$name=$_GET['t1'];
echo "Welcome ".$name."....!<br><br>";
echo "Hello".$_GET['t1'];
?>