【发布时间】:2019-08-04 19:59:07
【问题描述】:
嘿,所以我目前正在处理一个 html/php 页面。
我有一个应该包含在我的页面中的头文件,但由于某种原因它无法正常工作,我不知道,我对所有其他页面都做了同样的事情,它已经工作了,所以我没有不知道为什么突然不行了。
<?php
include 'header.php';
?>
<center>
<p>
This page utilizes several postgreSQL method calls. Such as pg_connect(),
pg_query(), and pg_fetch_result().
</p>
<!-- setup the table -->
<table border="1" width="75%">
<tr><th width="50%">Make</th><th width="15%">Model</th><th width="20%">Year</th><th width="15%">MSRP</th></tr>
<?php
$output = ""; //Set up a variable to store the output of the loop
//connect
$conn = pg_connect("host=127.0.0.1 dbname=slotegraafd_db user=slotegraafd password=100658347" );
//issue the query
$sql = "SELECT automobiles.make, automobiles.model, automobiles.year, automobiles.msrp
FROM automobiles
ORDER BY automobiles.year ASC";
$result = pg_query($conn, $sql);
$records = pg_num_rows($result);
//generate the table
for($i = 0; $i < $records; $i++){ //loop through all of the retrieved records and add to the output variable
$output .= "\n\t<tr>\n\t\t<td>".pg_fetch_result($result, $i, "Make")."</td>";
$output .= "\n\t\t<td>".pg_fetch_result($result, $i, "Model")."</td>";
$output .= "\n\t\t<td>".pg_fetch_result($result, $i, "Year")."</td>";
$output .= "\n\t\t<td>".pg_fetch_result($result, $i, "msrp")."</td>\n\t</tr>";
}
echo $output; //display the output
?>
</table>
<!-- end the table -->
</center>
</body>
</html>
这是我完整的包含语句的代码集。没有打开的 html 或 body 标记,因为它在头文件中,因此我不应该在此页面中添加它。 有什么帮助吗?
谢谢。
【问题讨论】:
-
你这是什么意思?