LIST DATA FROM MYSQL TABLE USED PHP
<html>
<head>
<title>php and mysql by sam saifi</title>
</head>
<body>
Fetching data into mysql table on localhost
step by step
step1:- create connection to data like $con.
step2:-select database like $db.
step3:- write query like $sql.
step4:-fetching data in loop like while loop
step5:- create object in loop like $row.
step6:-execute object with table colum name like $row['name'];
<?
$con = mysql_connect("localhost","sam","") or die(mysql_error());// here sam is user name
$db = mysql_select_db("sam");//here sam is data base name
$sql = "SELECT * FROM cust";
$query = mysql_query($sql) or die ("error Query [".$sql."]");
?>
<table >
<tr>
<th > <div >id </div></th>
<th > <div >name </div></th>
<th > <div >e-mail </div></th>
<th > <div >School </div></th>
</tr>
<?
while($row = mysql_fetch_array($query))
{
?>
<tr>
<td><div ><?php $row["id"];?></div></td>
<td><?php $row["name"];?></td>
<td><?php $row["e-mail"];?></td>
<td><div ><?php $row["School"];?></div></td>
</tr>
<?
}
?>
</table>
<?
mysql_close($con);
?>
</body>
</html>
<!--- php tutorials with sam saifi -->
<html>
<head>
<title>php and mysql by sam saifi</title>
</head>
<body>
Fetching data into mysql table on localhost
step by step
step1:- create connection to data like $con.
step2:-select database like $db.
step3:- write query like $sql.
step4:-fetching data in loop like while loop
step5:- create object in loop like $row.
step6:-execute object with table colum name like $row['name'];
<?
$con = mysql_connect("localhost","sam","") or die(mysql_error());// here sam is user name
$db = mysql_select_db("sam");//here sam is data base name
$sql = "SELECT * FROM cust";
$query = mysql_query($sql) or die ("error Query [".$sql."]");
?>
<table >
<tr>
<th > <div >id </div></th>
<th > <div >name </div></th>
<th > <div >e-mail </div></th>
<th > <div >School </div></th>
</tr>
<?
while($row = mysql_fetch_array($query))
{
?>
<tr>
<td><div ><?php $row["id"];?></div></td>
<td><?php $row["name"];?></td>
<td><?php $row["e-mail"];?></td>
<td><div ><?php $row["School"];?></div></td>
</tr>
<?
}
?>
</table>
<?
mysql_close($con);
?>
</body>
</html>
<!--- php tutorials with sam saifi -->
Comments
Post a Comment