PREV和NEXT使用PHP和MYSQL的GET函数

时间:2017-09-15 11:39:01

标签: php mysql

我有一个上一个和下一个按钮,我不知道如何使用get函数减少和增加id。任何人都可以帮忙,谢谢你。

以前的按钮代码

<?php
include('db.php');
//now execut Select statement on table
$title = $_GET['title'];

$SQL = mysqli_query($db, "
    SELECT * 
    FROM imageverse 
    WHERE ( 
        id = IFNULL((SELECT max(id) FROM imageverse WHERE id < id='".$title."'),0)
    );"
);

while ($row = mysqli_fetch_array($SQL)) {
    $date = $row['date'];
    $title = $row['title'];
    echo "<h3>Prev - <a href = 'bibleread_post1.php?title=" . $title . "'#top'>". $title ."</a></h3>";
}
// Close your database connection
mysqli_close($db_conx);
?>

下一个按钮代码

<?php
include('db.php');
//now execut Select statement on table
$title = $_GET['title'];

$SQL = mysqli_query($db, "
    SELECT * FROM imageverse 
    WHERE ( 
        id = IFNULL((SELECT min(id) FROM imageverse WHERE id > id='".$title."'),0) 
    );"
);

while ($row = mysqli_fetch_array($SQL)) {
    $date = $row['date'];
    $title = $row['title'];
    echo "<h3><a href = 'bibleread_post1.php?title=" . $title . "'#top'>". $title ."</a> - Next</h3>";
}
// Close your database connection
mysqli_close($db_conx);
?>

0 个答案:

没有答案