Program:
Output:
<?php
$host = "localhost";
$user = "root";
$pass = "1234";
$dbname = "employees";
$conn = mysqli_connect($host,$user,$pass,$dbname);
if(!$conn)
{
die('Could Not Connect:'.mysqli_errort());
}
echo "Connected Successfully: <br>";
$sql = "Select * from emp";
$retval = mysqli_query($conn,$sql);
if(mysqli_num_rows($retval)>0)
{
while($row = mysqli_fetch_assoc($retval))
{
echo "-------------<br>";
echo "EmpID: {$row['id']} <br>";
echo "Name: {$row['name']} <br>";
echo "Salary: {$row['Salary']} <br>";
echo "-------------<br>";
}
}
else
{
echo "0 results";
}
mysqli_close($conn);
?>
Output: