Location: PHPKode > projects > Private Movie Database > pmdb_V_B_0.3.0/code/pmdb/forum/fhome.inc
<?
/* filename: fhome.inc
 * project: movie database
 * author: lex alexander
 * originally coded: 10.07.2003
 * last modified: 14.07.2003
 * version V0.3
 * usage: Display Forums
 */

$status = $_COOKIE["pmdb_sid"];

$get_forum = "SELECT * FROM tb_forum";
$result_forum = mysql_query($get_forum)
  or die(QUERY_FAIL);

$rows_forum = mysql_num_rows($result_forum);
?>
<h1><?=PMDB_FORUM;?></h1>
<p><a href = "index.php?page=fhome">Forum</a> > Forum Index </p>
<table class = "table-forum">

<td class = "forum-head">&nbsp</td>
<td class = "forum-head"><?=FORUM ;?></td>
<td class = "forum-head"><?=NR_THREADS ;?></td>
<td class = "forum-head"><?=NR_POSTS ;?></td>
<td class = "forum-head"><?=LAST_POST ;?></td>

<?
while($rows_forum = mysql_fetch_array($result_forum))
{
  if($rows_forum["admin_only"] == 1 && $status != 1)
    continue;

  if($data_count % 2 == 0)
  {
    $data = "forum-data data-one";
    $data_title = "forum-title title-one";
  }
  else
  {
    $data = "forum-data data-two";
    $data_title = "forum-title title-two";
  }
  $data_count++;
  $fid = $rows_forum["fid"];

  // get number of threads
  $get_nr_threads="SELECT COUNT(*) as nr_threads FROM tb_thread WHERE r_fid = $fid";
  $result_nr_threads = doQuery($get_nr_threads);
  extract(mysql_fetch_array($result_nr_threads));

  // get number of posts
  $get_nr_posts="SELECT COUNT(*) as nr_posts FROM tb_post as p, tb_thread  as t WHERE p.r_tid = t.tid and t.r_fid = '$fid'";
  //print($get_nr_posts);
  $result_nr_posts = doQuery($get_nr_posts);
  extract(mysql_fetch_array($result_nr_posts));

  if($nr_posts > 0)
  {
    // get newest thread thread
    $get_newest_thread="SELECT ptitle, pid, r_uid from tb_thread as t, tb_post as p WHERE t.r_pid = p.pid AND t.r_fid = '$fid' ORDER BY pid DESC LIMIT 1";
    $result_newest_thread = doQuery($get_newest_thread);
    extract(mysql_fetch_array($result_newest_thread));

    // get User
    $get_user="SELECT uname from tb_user WHERE uid = '$r_uid'";
    $result_user = doQuery($get_user);
    extract(mysql_fetch_array($result_user));
  }
  else
  {
    $ptitle = "No post yet";
    $uname = "nobody";
  }
  ?>
  <tr>
    <td class = "ka"><?=$data_count;?></td>
    <td class = "<?=$data_title;?>"><a href="index.php?page=forum&amp;fid=<?=$rows_forum["fid"];?>"><?=$rows_forum["forum"];?></a></td>
    <td class = "<?=$data;?>"><?=$nr_threads;?></td>
    <td class = "<?=$data;?>"><?=$nr_posts ;?></td>
    <td class = "<?=$data;?>"><?=$ptitle ;?><br /> by <?=$uname;?></td>
  </tr>

  <?
}
?>
</table>
Return current item: Private Movie Database