tags:

views:

48

answers:

1

I have a "Jump To"-select box on my forum.

I want the forum that the thread I'm currently viewing to be SELECTED in the selectmenu.

I tried this:

$threadinfo = mysql_query("SELECT * FROM threads WHERE id = $threadid");
$thread = mysql_fetch_assoc($threadinfo);

$forums = mysql_query("SELECT * FROM forums ORDER BY name ASC");

while($forum = mysql_fetch_object($forums)) {

// select the forum that the thread currently viewed is located in
if ($forum->id == $thread->fid)
 echo '<option value="'.$board->id.'" SELECTED>'.htmlspecialchars($board->name).'</option>';
else
    echo '<option value="'.$forum->id.'">'.htmlspecialchars($forum->name).'</option>';
}

But It doesnt select the correct one.

Im currently lookin at thread #2 which has fid = 2 but it selects forum # 4 in the select menu ./

+1  A: 

is this bit right ?

$thread = mysql_fetch_assoc

you are referencing it like an object in the code, not an array as fetched

$thread->fid
bumperbox