我有一个从数据库中提取类别的动态页面。这个页面是categories.php?CTGID=####
,CTGID
代表分类号。然后,每个产品都有一个分配给它的 ID。
当他们点击该类别中的产品时,它会进入一个页面Products.php?ID=###
。我想要创建的是当它们在产品页面中时有一个下一个和上一个按钮。
我基本上需要它做的是获取CTGID
当前产品 ID,然后下一个按钮将是具有该类别 ID 的下一个产品的 ID。
<?php
$db=mysql_connect ("localhost",[username],[password]) or die(mysql_error());
mysql_select_db("rentals");
$rentID = $_GET['ID'];
//Strip html
$strip_ID = strip_tags($rentID);
$html = htmlentities($strip_ID, ENT_QUOTES);
$escape = addslashes($html);
$table="online_rental_db";
$sql = "SELECT * FROM $table WHERE ID=$escape";
$query = mysql_query($sql) or die(mysql_error());
$rentals = mysql_fetch_assoc($query);
$description = ucwords(strtolower($rentals['Description']));
$image = $rentals['Image'];
$download = $rentals['PDF'];
$ID = $rentals['ID'];
$CTGID = $rentals['CTGID'];
$category = $rentals['Category'];
$video = $rentals['Video'];
$bytes = filesize("rentals/".$download);
$model = $rentals['Model'];
$made = ucwords(strtolower($rentals['Manufacturer']));
$productnum = $rentals['Productnum'];
然后在页面上我只是呼应我在哪个区域需要什么。我已经阅读了一些关于下一个和上一个按钮的文章,但决定我可能需要一些额外的建议!