我有一个mytable
包含这些列的表string
pagename
我必须提取 $pagename 但我还需要提取此行下方的下一个 $pagename 以进行页面导航。例如,如果我需要该$pagename
值WHERE string='100001'
,我将需要$string
等于$nextpagestr=($currentline['string']+1);
或的下一页名称100002
(知道 $sql 的右大括号在 $sql2 之后)
我已经尝试了下面的代码,但是当我将链接悬停时,它显示Array.php
的不是我期望的值
<?php
include 'includes/connectdb.php';
$sql="select * from mytable where string=100001";
$result=mysql_query($sql);
while($currentline=mysql_fetch_assoc($result))
{
extract($currentline);
$nextpagestr=($currentline['string']+1);
$previouspagestr=($currentline['string']-1);
?>
<!-- SOME CODE HERE ... --> <?php echo $currentline['pagename']; ?>
<!-- THEN MY NAVIGATION: -->
<a class="next-link" href="<?php
$sql2='SELECT pagename FROM mytable WHERE string=$nextpagestr';
$result2 = mysql_query($sql2);
while($pagename=mysql_fetch_assoc($result2))
{echo($pagename);} ?>.php">Next Page</a>
<?php } ?> <!-- CLOSING BRACE FOR THE FIRST $SQL -->