Categories
PHP

How To Display Data In PHP From MySql

How To Display Data In PHP From MySql

In this tutorial i will teach you How To Display Data In PHP From MySql.This tutorial will be very helpful when you are thinking of fetching some data from mysql database to represent it through your php code.

CODE:

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>How To Display Data In PHP From MySql</title>
<style type="text/css">
body
{
margin:0px auto;
width:980px;
font-family:"Trebuchet MS", Arial, Helvetica, sans-serif;	
}
h2
{
font-size:30px;
text-align:center;	
}
.text
{
color:#090;
text-align:center;
font-size:14px;
border:solid 1px #ccc;	
text-align:center;
width:100%;
}
.hr
{
clear:both;	
margin-top:60px;
border-bottom:solid 2px rgba(0,0,0,0.4);
}
.footer
{
width: 100%;
text-align: center;
padding-top: 0px;
font-size: 16px;
}
</style>
</head>

<body>
<h2>How To Display Data In PHP From MySql</h2>
<div>
<table class="text">
<tr>
<td style="width:50%;background-color:#ccc;border-bottom:solid 1px #000">Firstname</td>
<td style="width:50%;background-color:#ccc;border-bottom:solid 1px #000">Lastname</td>
</tr>
<?php
mysql_connect("localhost","joon","joon");

mysql_select_db("my_db");

$order = "SELECT * FROM persons limit 0,10";
$result = mysql_query($order);
while($data = mysql_fetch_row($result)){
echo("<tr><td>$data[0]</td><td>$data[1]</td></tr>");
}
?>
</table>
</div>

<!--hr-->
<br /><br />
<hr />

<!--footer-->
<div class="footer">
<p>&copy; 2013 All rights reserved by HighTechnology.in
<a href="http://hightechnology.in" target="_blank">HighTechnology.in</a>
| Hosting Partner <a href="http://www.grootstech.com" target="_blank">Grootstech Solutions</a></p>
</div>
</body>
</html>

One reply on “How To Display Data In PHP From MySql”

Thank you for this article. That’s all I can say. You most definitely have made this blog into something special. You clearly know what you are doing, you’ve covered so many bases.Thanks!

Comments are closed.