0
我在我的論壇上有一個「Jump To」選擇框。簡單的php/mysql問題
我想我目前觀察線程在selectmenu被選擇的論壇。
我嘗試這樣做:
$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>';
}
但它不選擇正確的一個。
即時通訊目前在看着螺紋#2已經FID = 2,但在選擇菜單./
? – BoltClock 2010-07-12 10:26:19
也許這是因爲您在'selected'代碼中使用'$ board'變量而不是'$ forum'變量。 – NikiC 2010-07-12 10:26:23
而且你也應該把它合理化爲一個單一的數據庫查詢......它會更快 – 2010-07-12 10:28:50