Retrieving Data From Mysql Db Using Php

Retrieving Data From Mysql Db Using Php

<?php
$con=mysql_connect("localhost","root","");

//in d abv lyn d root is the default username of mysql nd password="" by default
// localhost is nthng bt a server tcp/ip>";

if(!$con)
{
echo "error ";
}
else
{
echo "mysql db has connected successfully";
}
mysql_select_db("my_test_db",$con);
// "<!-- select db from mysql-->";
$result = mysql_query("SELECT * FROM `my_test_tbl`") ;
print("<font size=> ");
print(" <br/>   <b> Name     &nbsp  &nbsp Inspire </b> \n");
print("</font>");

// echo "<!-- (here v cn us MYSQL_ASSOC or MYSQL_ID)MYSQL_BOTH - fetch Data from result set using ID as well as NAME  -->";
while($row=mysql_fetch_array($result,MYSQL_BOTH))
{
echo "<br/>" . $row[0];
printf( " &nbsp  &nbsp %s  ",$row["inspire"]);
}
mysql_free_result($result);
// mysql_close($con);
?>

No comments:

Post a Comment

Pages