Showing posts with label get data from mysql database in php. Show all posts
Showing posts with label get data from mysql database in php. Show all posts

Wednesday, 11 September 2013

Display in Drop down list from mysql database in php

//Display in Drop down list from mysql database in php 

<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Untitled Document</title>
</head>

<body>
<?php
mysql_connect('localhost', 'root', '');
mysql_select_db('bnr');

$sql = "SELECT name FROM reg";
$result = mysql_query($sql);

echo "<select name='name'>";
while ($row = mysql_fetch_array($result)) {
    echo "<option value='" . $row['name'] ."'>" . $row['name'] ."</option>";
}
echo "</select>";

?>
</body>
</html>

Tuesday, 9 July 2013

Get data From data base in php mysql

// Get data From data base in php mysql

<?php
$con=mysql_connect("localhost","root","");
$db=mysql_select_db("bnr");
$sql="select *from reg";
$query=mysql_query($sql);
while($row = mysql_fetch_array($query))
  {
  $username=$row['username'];
  echo  $row['username'] 
  echo  $row['name'] 
  echo  $row['password'] 
  echo  $row['emp_id'] 
  echo  $row['phone_no'] 
  echo  $row['email_id'] 
  echo  $row['address'] 
  }
mysql_close($con);
?>
<html>
<head></head>
<body>
</body>
</html>

Get data from Mysql DataBase in PHP (Display in Table)

// Get data from Mysql DataBase in PHP (Display in Table)

<?php
$con=mysql_connect("localhost","root","");
$db=mysql_select_db("bnr");
$sql="select *from reg";
$query=mysql_query($sql);

 echo "<table border='1'>
<tr>
<th>User Name</th>
<th>Name</th>
<th>password</th>
<th>Emp ID</th>
<th>Phone No</th>
<th>Email ID</th>
<th>Address</th>
</tr>";

while($row = mysql_fetch_array($query))
  {
 $username=$row['username'];
  echo "<tr>";
  echo "<td>" . $row['username'] . "</td>";
  echo "<td>" . $row['name'] . "</td>";
  echo "<td>" . $row['password'] . "</td>";
  echo "<td>" . $row['emp_id'] . "</td>";
  echo "<td>" . $row['phone_no'] . "</td>";
  echo "<td>" . $row['email_id'] . "</td>";
  echo "<td>" . $row['address'] . "</td>";
  echo "</tr>";
  }

mysql_close($con);




?>
</table>
<html>
<head></head>
<body>
</body>
</html>