每次我在 html 中运行 php 时,无论顺序如何,php 总是最后运行。例如; 当我运行这个:
<h2>Admin: Events</h2>
<form action="php/admin_event.php" method="post">
Event Name:<input type="text" name="event"><br>
Start Date:<input type="date" name="startdate"><br>
Start Time:<input type="time" name="starttime"><br>
Finish Date:<input type="date" name="finishdate"><br>
Finish Time:<input type="time" name="finishtime"><br>
Venue:<input type="text" name="venue"><br>
<input type="submit" name="submit">
</form>
<table border='1'>
<tr>
<th>Event</th>
<th>Start Time</th>
<th>Start Date</th>
<th>Finish Time</th>
<th>Finish Date</th>
<th>venue</th>
</tr>
<?php
$con = mysqli_connect("localhost","root","","littleathletics");
if(mysqli_connect_errno($con)){
echo "Failed to connect to MySQL.";
}
$result = mysqli_query($con,"SELECT * from events");
while($row = mysqli_fetch_array($result)){
?>
<tr>
<td><?=$row['Event'];?></td>
<td><?=$row['StartTime'];?></td>
<td><?=$row['StartDate'];?></td>
<td><?=$row['FinishTime'];?></td>
<td><?=$row['FinishDate'];?></td>
<td><?=$row['Venue'];?></td>
</tr>
<?php
}
mysqli_close($con);
?>
<hr>
<h2>Admin: Downloads</h2>
<form action="php/admin_downloadupload.php" method="post" enctype="multipart/form-data">...etc
如果(例如)你好在再见之前出现,我会更喜欢它。我的代码有问题吗?如果没有,有没有办法达到预期的结果?
由于我要呈现的 sql 数据,我需要用 php 编写一些部分。
编辑:整个表格显示在 html 文档的最后。