有人可以帮我分页这个脚本吗?我对它不是很好,我一直在搞砸。
我已经尝试检查 num_rows ,然后使其验证和填充,但它失败了 10 次 :( 2 天后我放弃了。我想从头开始。
<?php
$link = mysqli_connect("localhost", "lunar_lunar", "", "lunar_users");
if (mysqli_connect_errno()) {
printf("Connect failed: %s\n", mysqli_connect_error());
exit();
}
$result = mysqli_query($link, "SELECT * FROM users ORDER BY username");
while($row = mysqli_fetch_assoc($result)) {
$id=$row['id'];
$username=$row['username'];
$email=$row['email'];
$firstname=$row['firstname'];
$lastname=$row['lastname'];
$motto=$row['motto'];
$bio=$row['bio'];
$result4 = mysqli_query($link, "SELECT * FROM photo where id='$id'");
$row4 = mysqli_fetch_assoc($result4);
$image=$row4['filename'];
$src = (empty($image)) ? "upload/your-photo.jpg" : "site_images/$id/$image";
$motto = (empty($motto)) ? "No motto" : $motto;
$bio = (empty($bio)) ? "No biography" : $bio;
echo "<div class='panel panel-default'>
<div class='panel-heading'>
<h3 class='panel-title'><a href='public.php?id=".$id."'>".$username."</h3></a>
</div>
<div class='panel-body'>
<div class='gravatar span3' style='padding:0px;margin:0px;'>
<img src='
".$src."' alt='' width='85' height='85'>
</div>
<br />
<div class='page-header'>
<br />
</div>
<p style='margin-right:450px;'>
".$bio."
</p>
</div>
<div class='panel-footer'>".$motto."</div>
</div>";
}
?>