Skip to content

Instantly share code, notes, and snippets.

@Equinox-
Created July 3, 2012 19:21
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Equinox-/3042146 to your computer and use it in GitHub Desktop.
Save Equinox-/3042146 to your computer and use it in GitHub Desktop.
Fetches all the topics in the given forum.
<?php
$mysql_host = "";
$mysql_database = "devoxstu_smf391";
$mysql_user = "";
$mysql_password = "";
$forum = 1;
mysql_connect($mysql_host, $mysql_user, $mysql_password)or die("cannot connect");
mysql_select_db($mysql_database)or die("cannot select DB");
//Grab the topics
$sql = "SELECT * FROM `smf_topics` WHERE `id_board` ='$forum' ORDER BY `id_topic` DSC;";
$result = mysql_query($sql);
if ($result !== FALSE) {
$topics = array();
while ($arr = mysql_fetch_array($result)) {
array_push($topics,$arr);
}
mysql_free_result($result);
foreach ($topics as $topic) {
$sql = "SELECT * FROM `smf_posts` WHERE `id_msg` ='".$topic['id_first_msg']."';";
$sResult = mysql_query($sql);
if ($sResult !== FALSE) {
$post = mysql_fetch_array($sResult);
if ($post !== FALSE){
echo "<b>".$post['subject']."</b><br />";
echo parse_bbc($post['body']);
echo "<hr>";
}
mysql_free_result($sResult);
}
}
}
mysql_close();
?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment