PHPで簡単なページネーションを構築しようとしています。しかし、何らかの理由でエラーが出力され続けます。問題が見つからないようです。これが私のコードです:
PHP:
include_once('connect.php'); // connect to db is successful
$count_query = mysql_query("SELECT NULL FROM users");
$count = mysql_num_rows($count_query);
// pagination starts here
if (isset($_GET['page'])) {
$page = preg_replace("#[^0-9]#", "", $_GET['page']);
} else {
$page = 1;
}
$perPage = 5;
$lastPage = cell($count / $perPage);
if ($page < 1) {
$page = 1;
} else if ($page > $lastPage) {
$page = $lastPage;
}
$limit = "LIMIT " . ($page - 1) * $perPage . ", $perPage";
$query = mysql_query('SELECT first_name FROM users ORDER BY user_id DESC $limit');
if ($lastPage != 1) {
if ($page != $lastPage) {
$next = $page + 1;
$pagination .= '<a href="index.php?page=' . $next . '">Next</a>';
}
if ($page != $lastPage) {
$prev = $page - 1;
$pagination .= '<a href="index.php?page=' . $prev . '">Previous</a>';
}
}
while ($row = mysql_fetch_array($query)) {
$output .= $row['first_name'] . '<hr />';
}
HTML :
<!DOCTYPE html>
<html>
<head>
<title>Pagination</title>
</head>
<body>
<h1>My Pagination</a>
<?php echo $output; ?>
<?php echo $pagination; ?>
</body>
</html>
タイトルで述べたように、私は"Fatal error: Call to undefined function cell()"
. 私は修正に何時間も費やしましたが、まだ運がありません。皆さんがそれを理解して、何が問題なのか教えてくれることを願っています。