Wednesday, February 22, 2012

Show data from Mysql using PHP


This program is for connect PHP with Mysql Database . Just copy and paste following code and edit according to your database connection.
My database information is like this
Database:-localhost
Username:-root
Password:-
Tablename:-login




<?php
$conn=mysql_connect("localhost","root","");
if($conn==NULL)
 echo "Database connection failure";
$db=mysql_select_db("asp",$conn);
if($db==NULL)
 echo "Database selection failure";
$qur="select * from login";
$result=mysql_query($qur);
while($row=mysql_fetch_array($result))
{
  echo $row['username'];
  echo "<br>";
  echo $row['password'];
}
?>

No comments:

Post a Comment