Connect to MySQL database and fetch data from MySQL table and display in html Topic is solved

HTML, PHP, CSS, Javascript, AJAX.............
sudheer1994
Posts: 2
Joined: Tue Jan 15, 2019 3:30 pm
Location: Hyderabad
Mood:
Age: 25
India

Connect to MySQL database and fetch data from MySQL table and display in html

Post by sudheer1994 » Fri Jan 18, 2019 8:56 pm

I want to get data from MySQL database and display in html table

User avatar
indhosting
Posts: 5
Joined: Tue Jan 15, 2019 1:23 pm
India

Re: Connect to MySQL database and fetch data from MySQL table and display in html

Post by indhosting » Fri Jan 18, 2019 9:18 pm

Code: Select all

<?php include 'header.php';
$con = mysqli_connect( "xyz.com","nano","itsacar","my_db" );
$sql = "SELECT * FROM cars";
$result = $con->query($sql);
	
echo "<table border='1'>
<tr>
<th>Name</th>
<th>Model</th>
</tr>";

while($array= mysqli_fetch_array($result))
{
echo "<tr>";
echo "<td>" . $array['Name'] . "</td>";
echo "<td>" . $array['Model'] . "</td>";
echo "</tr>";
}
echo "</table>";

mysqli_close($con);
?>
Hope it works for you :D 8-)

Post Reply Previous topicNext topic