Php代码显示在我的页脚

时间:2016-03-11 09:33:41

标签: php html

我的php代码出现了问题,这些代码在我的页脚下显示出来。我通过在另一个文件中添加php来尝试所有内容,并在我的代码中包含php文件但也无法正常工作。有趣的是,当我复制代码并将其粘贴到我的页脚下显示的PHP代码下,并且一个显示在它应该的位置。

<!-- LINK FOR TABLE CSS -->
<!-- LINK VOOR TABEL CSS -->                        
<link rel="stylesheet" type="text/css" href="css/table.css">
<?php

$servername = "localhost";
$username = "root";
$password = "usbw";
$dbname = "persons";

// CREATE A CONNECTION WITH THE DATABASE
// CONNECTIE MAKEN MET DATABASE
$conn = new mysqli($servername, $username, $password, $dbname);
if ($conn->connect_error) {
    die("Connection failed: " . $conn->connect_error);
} 

// SELECT TABLE NAMES FROM PERSON, ADDRESS AND CV WHERE address_id IS person_address and cv_id IS person_cv
// SELECTEER VAN TABEL PERSON, ADDRESS AND CV WAAR address_id  GELIJK IS AAN person_address EN cv_id AAN person_cv
$sql = "SELECT person_id, person_firstname, person_lastname, 
                 person_email, person_phonenumber,  
                 address_street,address_housenumber, 
                 address_city,address_state,address_zipcode, cv_path
          FROM person 
            inner join address on address.address_id = person.person_address 
            inner join cv on cv.cv_id = person.person_cv";

// EXECUTE QUERY IF THE RESULT BIGGER IS THAN ZERO
// VOER QUERY UIT ALS RESULTAAT GROTER IS DAN NUL
$result = $conn->query($sql);
if ($result->num_rows > 0) {

// ECHO A TABLE WITH VALUES 
// ECHO EEN TABEL MET ONDERSTAANDE WAARDES
echo "<form action='admin.php' method='post'>"; 
echo "<table border=0 align=right>
<tr>
<th>Voornaam</th>
<th>Achternaam</th>
<th>Straat</th>
<th>Huisnummer</th>
<th>Postcode</th>
<th>Stad</th>
<th>Provincie</th>
<th>Email</th>
<th>Mobiel</th>
<th>cv</th>
<th>delete</th>
</tr>";

// LOOP THROUGH THE RESULTS AND OUTPUT THE RESULTS FOR EACH ROW
// GA DOOR RESULTATEN EN LAAT DE RESULTEN PER RIJ ZIEN
while($row = $result->fetch_assoc()) {
     echo "<tr>";
     echo "<td>" . $row["person_firstname"] . "</td>";
     echo "<td>" . $row["person_lastname"] . "</td>";
     echo "<td>" . $row["address_street"] . "</td>";
     echo "<td>" . $row["address_housenumber"] . "</td>";
     echo "<td>" . $row["address_zipcode"] . "</td>";
     echo "<td>" . $row["address_city"] . "</td>";
     echo "<td>" . $row["address_state"] . "</td>";
     echo "<td>" . $row["person_email"] . "</td>";
     echo "<td>" . $row["person_phonenumber"] . "</td>";
     echo "<td><a href='http://localhost:8080/website/" . $row['cv_path'] . "'>cv file</a></td>";
     echo "<td><a href='delete.php?person_id=" . $row['person_id'] . "'>delete</a></td>";
     echo "</tr>";
  }
  echo "</form>";
 }

// IF THERE IS ZERO RESULT ECHO THIS
// ALS WAARDE NUL IS LAAT DE ONDERSTAADE TEKST ZIEN
else {
    echo "<p id='Tekst'>Er zijn geen deelnemers in de database gevonden.</p>";
  }
  // CLOSE CONNECTION
  // SLUIT CONNECTIE
  $conn->close();
  ?>        

link2 link3

我注意到的另一件事......当我一个接一个地回声时,它确实只用一个数据库中的值显示了正确位置的表...它还显示了其他值,但它没有显示出来表

2 个答案:

答案 0 :(得分:2)

看起来你没有关闭<table>

答案 1 :(得分:1)

您似乎在结束</table>代码之前错过了结束</form>代码。