PHP Retrieve Data (While loop)

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Untitled Document</title>
</head>

<body>
<?php
$username = "root";
$password = "";
$hostname = "localhost";
$database = "infra";

$conn = mysql_connect($hostname, $username, $password)
 or die("Connecting to MySQL failed");

mysql_select_db($database, $conn)
 or die("Selecting MySQL database failed");

$data = mysql_query("select * from search");
 while($info = mysql_fetch_array( $data ))
 {
 Print "<th>Name:</th> <td>".$info['name'] . "---";
 Print "<th>type:</th> <td>".$info['type'] . " <br>";
 }

?>
</body>
</html>

No comments:

Post a Comment