我有一个表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 -->
答案 0 :(得分:0)
嗯....
$result2 = mysql_query($sql2);
while($currentline=mysql_fetch_assoc($result2))
{
extract($currentline);
echo($currentline['pagename']); ?>.php">Next Page</a>
<?php } ?>