views:

86

answers:

2

excuse the title but as im not an expericened programmer i dont know how to describe this problem

So the problem. I have 2 topics in my topics table. When im on thread 2 it correclty prints a thread to thread 1 but when im on thread 1 it doesnt print the link to thread 2.

Whats wrong?

$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 ?>
+3  A: 

I think its the "<" you have before "Previous Topic". Change that to a &lt;

Grumdrig
And the `>` in the next topic link to `>`
BoltClock
still dont work
Basta
A: 

I see no reason why the following shouldn't work:

<?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; ?>

Try it.

Alix Axel