This post is used to Display the data from database table in simple way . It is easy to understand the learner to how to display the data from database in simple way.
Create Database
create database getinsearch;
CreateTables:
CREATE TABLE `getinsearch`.`san` (
`companyname` VARCHAR( 150 ) NOT NULL ,
`address` VARCHAR( 350 ) NOT NULL ,
`contactnumber` INT( 200 ) NOT NULL ,
`mail` VARCHAR( 200 ) NOT NULL ,
`url` VARCHAR( 150 ) NOT NULL ,
`category` VARCHAR( 80 ) NOT NULL
) ENGINE = MYISAM ;
db.php
<?php
$conn=mysql_connect('localhost','root','') or die(mysql_error());
mysql_select_db("getinsearch",$conn);
?>
index.php
<?php
include('db.php');
$sql = 'SELECT companyname, address, contactnumber, mail, url, category FROM san';
$retval = mysql_query( $sql, $conn );
if(! $retval )
{
die('Could not get data: ' . mysql_error());
}
while($row = mysql_fetch_array($retval, MYSQL_ASSOC))
{
echo "COMPANY NAME :{$row['companyname']} <br> ".
"ADDRESS : {$row['address']} <br> ".
"CONTACT NUMBER : {$row['contactnumber']} <br> ".
"MAIL ID : {$row['mail']} <br> ".
"WEBSITE : {$row['url']} <br> ".
"CATEGORY : {$row['category']} <br> ".
"--------------------------------<br><br>";
}
mysql_close($conn);
?>
0 Comments