list data into mysql table in php
<html>
<head>
<title>php and mysql by sam saifi</title>
</head>
<body>
list data into mysql table in php
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'];
step7:- used mysql_num_field for count all field in table
step8:-execute for loop and eccho field 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."]");
$num = mysql_num_fields($query);
$i = 0;
echo "<b>$num.</b><br>";
for($i=1;$i<$num;$i++)
{
echo $i."=".mysql_field_name($query,$i)." (".mysql_field_type($query,$i).")<br>";
}
mysql_close($con);
?>
</body>
</html>
<!--- php tutorials with sam saifi -->
Comments
Post a Comment