Mam taką funkcję w PHP, która wyświetla losowe tematy:
function get_rand_topics($num) { if(!$num) $num = 20; $separator = " • "; $sql = "SELECT topic_id, topic_title, topic_replies, forum_id FROM " . TOPICS_TABLE . " ORDER BY RAND() LIMIT $num"; if(!($result = $db->sql_query($sql)) || !($db->sql_affectedrows($result))) { $num = 0; } else { while($row = $db->sql_fetchrow($result)) { $sfc['topics'][$row['topic_id']]['title'] = $row['topic_title']; $sfc['topics'][$row['topic_id']]['forum'] = $row['forum_id']; if($row['topic_replies'] >= $board_config['hot_threshold']) { $row['topic_title'] = str_replace($row['topic_title'], "<b>" . $row['topic_title'] . "</b>", $row['topic_title']); } $random_topics = $random_topics ? ($random_topics . $separator) . " <a href='" . append_sid('viewtopic.php?t=' . $row['topic_id']) . "' class='genmed'>" . $row['topic_title'] . "</a>" : " <a href='" . append_sid('viewtopic.php?t=' . $row['topic_id']) . "' class='genmed'>" . $row['topic_title'] . "</a>"; } } if($num) { } return $random_topics; }
Jak zrobić, aby losowe tematy nie były wyświetlane z forum_id 15,20,23?