Problems:
## Discuss the procedure of the storing data in MySQL and retrieving data from MySQL database using PHP program. 2010,2015
## How to Insert and retrieve data from MySQL database using Program

How to Insert and retrieving data from MySQL database using Program

 
<?php
$server_name = "localhost:3308";
$db = "tufan";
$user_name = "root";
$pass = "";

//Create Connection
$conn = new mysqli($server_name,$user_name,$pass,$db);

//Check Connectio
if(!$conn){
die ("Database problem!!!");
}
else{
echo "Connection Ok";
}

//insert data into Mysql database table

$a= "INSERT INTO boss(id,FastName,LastName) VALUES(1,'Tufan','islam')";
if(mysqli_query($conn,$a)){
echo "data insert ok";
}else{
echo "data insert failed";
}

//retriving (shows) data

$b="SELECT* FROM boss";
$result = mysqli_query($conn,$b);
if(mysqli_num_rows($result)>0){
while($row = mysqli_fetch_array($result)){
echo "<br>";
echo $row['FastName'];
echo "<br>";
echo $row['LastName'];
}
}else "no record";
?>

Outout:

Connection Ok
Tufan
islam

Screenshots of browser (output):



Post a Comment

Previous Post Next Post