PHP MySQL While Loop

*Note : To run while loop on MySQL table, you need to connect to MySQL database. Find below example.

To connect with MySQL you need to access connection with mySQL ,. Click here to get connection string for PHP & MySQL Connection.

<?php 

// '$con’ is the connection parameter

$query = "SELECT * FROM employee_table where employeeName='Michale Bode'";
$result = mysqli_query($con, $query);
while($row = mysqli_fetch_array($result))
{  
 echo "<span> Employee Name :". $row['eFullName']. "<span><br>";
 echo "<span> Employee ID :". $row['eID']. "<span><br>";
 echo "<span> Employee Mobile  :". $row['eMobile']. "<span><br>";
 echo "<span> Employee Address :". $row['eAddress']. "<span><br>";
}

?>

Output:
Employee Name: Michael S. Bode
Employee ID: A77199
Employee Mobile: +1 952-888-xxxx
Employee Address: 421 American Blvd E, Bloomington, MN 55425, USA

No comments :

Post a Comment

Leave A Comment...