0

我有一个mytable包含这些列的表string pagename

我必须提取 $pagename 但我还需要提取此行下方的下一个 $pagename 以进行页面导航。例如,如果我需要该$pagenameWHERE 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 --> 
4

1 回答 1

0

嗯……

 $result2 = mysql_query($sql2); 
 while($currentline=mysql_fetch_assoc($result2)) 
 {
     extract($currentline);
     echo($currentline['pagename']); ?>.php">Next Page</a>
 <?php } ?>
于 2013-11-13T18:27:39.143 回答