Login

Username:

Password: 

Join us Now |  Forgot Password? | Forgot UserName?

PHP

Learn step by step



Display Data

for display data from mysql database table select query are used to fetch data from table
syntax are select name from table where id=1; are used where we can use multiple condition in where case to display data.


<html>
<head>
<title>Search data</title>
</head>
<body>
<table>
<tr>
<td align="center">EMPLOYEES DATA</td>
</tr>
<tr>
<td>
<table border="1">
<tr>
<td>NAME</td>
<td>EMPLOYEES<br>NUMBER</td>
<td>ADDRESS</td>
</tr>
<?
//the example of searching data
with the sequence based on the field name
//search.php
mysql_connect("localhost","root","admin");//database connection
mysql_select_db("employees");

$order = "SELECT * FROM employees ORDER BY name";
//order to search data
//declare in the order variable

$result = mysql_query($order);
//order executes the result is saved
//in the variable of $result

while($data = mysql_fetch_row($result)){
echo("<tr><td>$data[1]</td><td>$data[0]</td><td>$data[2]</td></tr>");
}
?>
</table>
</td>
</tr>
</table>
</body>
</html>

It will show following output

EMPLOYEES DATA
NAME EMPLOYEES NUMBER ADDRESS
jai 001 India
Pankaj 002 India
Ramesh 003 Hindustan



Related Videos