ausgeführt wird Ich versuche, meine PHP while
Schleife innerhalb eines html
Echo Echo.Echo PHP, wenn MySQLi Abfrage
Im Grunde möchte ich in einem anderen Echo Echo. Ist das möglich?
Hier ist mein Code:
<?php
session_start();
require 'config.php';
if (@$_SESSION['username']) {
$query = "SELECT * FROM `crew_info`";
$query_run = mysqli_query($conn,$query);
echo '<!DOCTYPE html>
<html>
<head>
<title>All Crew</title>
</head>
<body>
<table>
<tr>
<th>First Name: </th>
<th>Middle Name: </th>
<th>Last Name: </th>
<th>Age: </th>
<th>Birth Date: </th>
<th>Birth Place: </th>
<th>Gender: </th>
<th>Martial Status: </th>
<th>Nationality: </th>
<th>Email Address: </th>
<th>Address 1: </th>
<th>Address 2: </th>
<th>Course: </th>
<th>School Graduated: </th>
<th>Remarks: </th>
<th>Date Added: </th>
<th>Status: </th>
</tr>
<tr>
while($record = mysqli_fetch_assoc($query_run)) {
echo "<tr>";
echo "<th>".$record['first_name']."</th>";
echo "<th>".$record['middle_name']."</th>";
echo "<th>".$record['last_name']."</th>";
echo "<th>".$record['age']."</th>";
echo "<th>".$record['birth_date']."</th>";
echo "<th>".$record['birth_place']."</th>";
echo "<th>".$record['gender']."</th>";
echo "<th>".$record['martial_status']."</th>";
echo "<th>".$record['nationality']."</th>";
echo "<th>".$record['email_address']."</th>";
echo "<th>".$record['address_1']."</th>";
echo "<th>".$record['address_2']."</th>";
echo "<th>".$record['course']."</th>";
echo "<th>".$record['school_graduated']."</th>";
echo "<th>".$record['remarks']."</th>";
echo "<th>".$record['date_added']."</th>";
echo "<th>".$record['crew_status']."</th>";
echo "</tr><br>";
</tr>
</table>
</body>
</html>';
}
}
else {
header('Location: /practice1/index.php');
}
?>
Ich hoffe jemand kann mir helfen
PHP funktioniert nicht so. Sie können Ihren Code auf einmal ausführen (tun Sie die tatsächlichen Echos, die Sie wollen, anstatt PHP zum Echo von PHP zu verwenden), oder Sie können eine Datei mit PHP speichern und sie später ausführen, vielleicht mit einem Include. Was versuchst du eigentlich? –
Ich versuche, alle Datensätze in der Tabelle zu echo. Wie Sie oben sehen können, ist der HTML-Code innerhalb einer if-Anweisung und sobald er korrekt ist, wird der gesamte HTML-Code ausgeführt. aber im Probleme, mit dem „Echo innerhalb echo“, was leider – unknown
Beachten Sie, dass für Konfigurationsdateien sollten Sie 'require_once()' eher dann 'require()' =] –