我是一个新手,刚刚开始建立一个网站..我写了以下代码,但它不起作用。它没有连接到数据库..如果没有,还有其他方法可以将 Dreamweaver 连接到 postgresql ...请帮助..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>