1 回答
TA贡献1806条经验 获得超5个赞
<?php
//connect to Atlas and include Composer files
require 'dbconnection.php';
require 'vendor/autoload.php';
$page = $_GET["page"];
if ($page=="" || $page=="1")
{
$page1=0;
}
else{
$page1=($page*5)-5;
}
$options=['limit' => 5,
'skip' => $page1
];
$query= $collection->find([], $options);
?>
<!DOCTYPE html>
<html>
<head>
<title>Results</title>
</head>
<body>
<table>
<tr>
<th>Film</th>
<th>Actor</th>
<th>Director</th>
<th>Year</th>
<th>Genre</th>
</tr>
<?php
foreach($query as $value) {
echo "<tr>";
echo "<td>".$value->film."</td>";
echo "<td>".$value->actor."</td>";
echo "<td>".$value->director."</td>";
echo "<td>".$value->year."</td>";
echo "<td>".$value->category."</td>";
echo "<td>";
echo "</tr>";
};
echo '</table>';
$countr=$collection->count($query);
$a=$countr/5;
$a=ceil($a);
echo "<br>"; echo "<br>";
for($b=1;$b<=$a;$b++)
{
?><a href="results.php?page=<?php echo $b; ?>" style="text-decoration:none "><?php echo $b." "; ?></a> <?php
}
?>
</body>
</html>
- 1 回答
- 0 关注
- 73 浏览
添加回答
举报