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

if(REGISTER_GLOBALS == "off");
{
  $fid = $_GET["fid"];
}
$get_forum_name="SELECT forum FROM tb_forum WHERE fid = '$fid'";
$result_forum = doQuery($get_forum_name);
extract(mysql_fetch_array($result_forum));
?>
<h1><?=PMDB_FORUM;?></h1>
<p> <p><a href = "index.php?page=fhome">Forum</a> > <a href = "index.php?page=forum&amp;fid=<?=$fid;?>"> <?=$forum;?></a> </p>
<p><a href = "index.php?page=newpost&amp;fid=<?=$fid;?>&amp;tid=0"><?=POST_NEW;?></a></p>
<?

$get_thread = "SELECT tid, ptitle FROM tb_thread as t, tb_post as p WHERE t.r_pid = p.pid AND  t.r_fid = '$fid'";
$result_thread = mysql_query($get_thread)
  or die(QUERY_FAIL);

$rows_forum = mysql_num_rows($result_thread);
?>

<table>
<td class = "movie-head">&nbsp;</td>
<td class = "movie-head"><?=THREAD;?></td>
<td class = "movie-head"><?=THREAD_STARTER;?></td>
<td class = "movie-head"><?=REPLIES;?></td>
<td class = "movie-head"><?=LAST_POST;?></td>

<?
while($rows_thread = mysql_fetch_array($result_thread))
{
  if($data_count % 2 == 0)
  {
    $data = "movie-data1";
    $data_title = "movie-title1";
  }
  else
  {
    $data = "movie-data2";
    $data_title = "movie-title2";
  }
  $data_count++;
  $tid = $rows_thread["tid"];

  // get first poster
  $get_first_poster = "SELECT uname as last_poster, time from tb_post as p, tb_user as u WHERE p.r_tid = '$tid' AND u.uid = p.r_uid ORDER BY pnr DESC LIMIT 1";
  $result_first_poster = doQuery($get_first_poster);
  extract(mysql_fetch_array($result_first_poster));

  // get last poster
  $get_first_poster = "SELECT uname as first_poster from tb_post as p, tb_user as u WHERE p.r_tid = '$tid' AND u.uid = p.r_uid ORDER BY pnr LIMIT 1";
  $result_first_poster = doQuery($get_first_poster);
  extract(mysql_fetch_array($result_first_poster));

  // 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.tid = '$tid'";
  $result_nr_posts = doQuery($get_nr_posts);
  extract(mysql_fetch_array($result_nr_posts));
  ?>
  <tr>
    <td class = "<?=$data;?>"><?=$data_count;?></td>
    <td class = "<?=$data_title;?>"><a href="index.php?page=thread&amp;fid=<?=$fid;?>&amp;tid=<?=$tid;?>"><?=$rows_thread["ptitle"];?></a></td>
    <td class = "<?=$data;?>"><?=$first_poster;?></td>
    <td class = "<?=$data;?>"><?=$nr_posts;?></td>
    <td class = "<?=$data;?>"><?=$last_poster;?> <?=$time;?></td>
  </tr>

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