我有一个表单,用于键入访客列表的联系人。在提交按钮被键入后,在同一页面上我想检索数据并显示访客列表。键入表单的数据在数据库中接收。但它们不会显示在HTML网站的屏幕上。
我邀请的顶部.HTML:
<?php
include("guestlist.php");
include("guestlist_connect.php");
?>
invites.HTML:
<h2 >Invites & Guest List</h2>
<table border="2">
<thead>
<tr>
<th>First Name</th>
<th>Last Name</th>
<th>Contact</th>
<th>Invitation</th>
</tr>
</thead>
<tbody>
<?php
include("guestlist_connect.php");
$result = mysql_query("SELECT * FROM guestlist");
while( $row = mysql_fetch_assoc( $result ) ){
?>
<tr>
<td><? php echo $row["fname"]; ?></td>
<td><? php echo $row["lname"]; ?></td>
<td><? php echo $row["email"]; ?></td>
<td><? php echo $row["contact"]; ?></td>
</tr>
<?php
</tbody>
</table>
<?php mysql_close($connector); ?>
</div><!--End Rightcontainer-->
</div>
_guestlist_connect.php:_
<?php
$servername = "localhost";
$username = "root";
$password = "";
$dbname = "registration";
$conn = mysqli_connect($servername, $username, $password, $dbname) or
die("Connection failed: " . mysqli_connect_error());
if (mysqli_connect_errno()) {
printf("Connect failed: %s\n", mysqli_connect_error());
exit();
}
?>
答案 0 :(得分:-1)
首先,您不需要重复 包括(&#34; guestlist_connect.php&#34); 而且你忘了在循环结束时结束
CREATE TABLE DEMO (COLA VARCHAR(10) NOT NULL, COLB VARCHAR(10) NOT NULL, COLC VARCHAR(10), COLD VARCHAR(10));
ALTER TABLE DEMO ADD CONSTRAINT DEMO_PK PRIMARY KEY (COLA, COLB);
CREATE INDEX DEMO_IX1 ON DEMO (COLB);
INSERT INTO DEMO VALUES ('A','B','C','D');
INSERT INTO DEMO VALUES ('A1','B1','C1','D1');
INSERT INTO DEMO VALUES ('A2','B2','C2','D2');
SELECT COLA,COLB FROM DEMO WHERE COLB='B1'