php / mysql新手问题

时间:2010-07-14 04:54:53

标签: php mysql html xhtml

原谅标题,但因为我不是一个经验丰富的程序员,我不知道如何描述这个问题

所以问题。 我的主题表中有2个主题。当我在线程2上时,它会将一个线程打印到线程1,但是当我在线程1上时,它不会打印到线程2的链接。

怎么了?

$prev_thread = mysql_query("SELECT MAX(id) as prev_thread_id
                            FROM topics
                            WHERE id < $threadid
                            AND boardid = 1");

$next_thread = mysql_query("SELECT MIN(id) as next_thread_id
                            FROM topics
                            WHERE id > $threadid
                            AND boardid = 1");

$prev = mysql_fetch_assoc($prev_thread);
    $next = mysql_fetch_assoc($next_thread);
?>
<?php if ($prev['prev_thread_id']): ?>
<b><a href="<?=URL?>/forum/?action=thread&amp;threadid=<?php echo   $prev['prev_thread_id']?>">< Previous Topic</a>&nbsp;&nbsp;&nbsp;&nbsp;</b>
<?php endif ?>

<?php if ($next['next_thread_id']): ?>
<b><a href="<?=URL?>/forum/?action=thread&amp;threadid=<?php echo    $next['next_thread_id']?>">Next Topic ></a></b>
<?php endif ?>

2 个答案:

答案 0 :(得分:3)

我认为它的“&lt;”你有“上一个主题”之前。将其更改为&lt;

答案 1 :(得分:0)

我认为没有理由说明以下情况不起作用:

<?php
$prev_thread = mysql_query("SELECT MAX(id) as prev_thread_id
                            FROM topics
                            WHERE id < $threadid
                            AND boardid = 1 LIMIT 1");

$next_thread = mysql_query("SELECT MIN(id) as next_thread_id
                            FROM topics
                            WHERE id > $threadid
                            AND boardid = 1 LIMIT 1");

$prev = mysql_fetch_assoc($prev_thread);
$next = mysql_fetch_assoc($next_thread);
?>
<?php if ($prev['prev_thread_id']): ?>
<b><a href="<?=URL?>/forum/?action=thread&amp;threadid=<?php echo $prev['prev_thread_id']?>">&lt; Previous Topic</a>&nbsp;&nbsp;&nbsp;&nbsp;</b>
<?php endif; ?>

<?php if ($next['next_thread_id']): ?>
<b><a href="<?=URL?>/forum/?action=thread&amp;threadid=<?php echo $next['next_thread_id']?>">Next Topic &gt;</a></b>
<?php endif; ?>

试试吧。