我有一个从数据库中查找结果的函数。我正在使用while loopwithmysqli_fetch_assoc()从数据库中获取结果。但是页面一直在加载并且没有显示任何错误。
环形
<?php while ($job = mysqli_fetch_assoc(find_all_jobs())) { ?>
<tr class="custom-table-body-titles">
<td><?php echo $job['updated-at']; ?></td>
<td>
<a href="#" class="text-dark"><?php echo $job['title']; ?></a>
</td>
<td>0/<?php echo $job['required_freelancers']; ?></td>
<td><?php echo $job['delivery_time']; ?> Days</td>
<td>$<?php echo $job['budget']; ?></td>
<td>
<a href="job_details.html" class="btn btn-sm btn-primary">Apply</a>
</td>
</tr>
<?php } ?>
功能
function find_all_jobs() {
global $connection;
$sql = "SELECT * FROM jobs ORDER BY job_id DESC LIMIT 10";
$stmt = mysqli_stmt_init($connection);
mysqli_stmt_prepare($stmt, $sql);
$result = mysqli_stmt_execute($stmt);
if(!$result) {
die("Database query failed." . mysqli_stmt_error($stmt));
}
return mysqli_stmt_get_result($stmt);
mysqli_stmt_close($stmt);
}
慕尼黑8549860