Welcome to ShenZhenJia Knowledge Sharing Community for programmer and developer-Open, Learning and Share
menu search
person
Welcome To Ask or Share your Answers For Others

Categories

I have a form that keys in the contacts of the guest list. On the same page itself after the submit button is keyed I want to retrieve the data and display the list of guest. The data keyed into the form is received in the database. But they are not being displayed on my screen on the HTML site.

top of my invites.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
", mysqli_connect_error());
  exit();
}
?>
See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
thumb_up_alt 0 like thumb_down_alt 0 dislike
185 views
Welcome To Ask or Share your Answers For Others

1 Answer

First, you do not need to repeat include("guestlist_connect.php"); And also you forgot to end while loop

  <?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 
    $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 } ?> // you forgot to end a while loop
    </tbody> </table> 
    <?php mysql_close($connector); ?> 
    </div><!--End Rightcontainer--> </div>

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
thumb_up_alt 0 like thumb_down_alt 0 dislike
Welcome to ShenZhenJia Knowledge Sharing Community for programmer and developer-Open, Learning and Share
...