我是新手,刚刚开始建立一个网站..我写了下面的代码,但它没有工作。它没有连接到数据库..如果不是这有任何其他方式将Dreamweaver连接到postgresql .. .please help..thnx提前
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<!-- Bootstrap -->
<link href="css/bootstrap.min.css" rel="stylesheet" media="screen">
</head>
<body>
<div class="span6">
<table class="table table-striped">
<thead>
<tr>
<th>Scheme-ID</th>
<th>Scheme Name</th>
<th>Scheme Type</th>
</tr>
</thead>
<tbody>
<?PHP
$conn = pg_connect("host=localhost port=5432 dbname=egram user=postgres password=password") or die("unable to connect to database");
if ($conn)
{
echo ("Connection attempt succeeded.");
}
else {
echo ("Connection attempt failed.");
}
$sql = "SELECT scheme_id,scheme_name,scheme_type FROM schemes";
$result = pg_query($conn,$sql); //order executes
if($result)
{
echo("query ran successfully");
while($data = pg_fetch_row($result))
{
echo("<tr><td>$data[0]</td><td>$data[1]</td><td>$data[2]</td></tr>");
}
}
else
{
echo("error in running query");
}
?>
</tbody>
</table>
</div>
<script src="http://code.jquery.com/jquery.js"></script>
<script src="js/bootstrap.min.js"></script>
<a href="#">#</a>
</body>
</html>