Location: PHPKode > projects > WH Community > wh_community/index.php
<?php require('layout/header.php'); ?>

<div id="content_wrapper">
    <div class="content"><?php

		$sql = "SELECT
					categories.cat_id,
					categories.cat_name,
					categories.cat_description,
					COUNT(topics.topic_id) AS topics
				FROM
					categories
				LEFT JOIN
					topics
				ON
					topics.topic_id = categories.cat_id
				GROUP BY
					categories.cat_name, categories.cat_description, categories.cat_id
				ORDER BY
					categories.cat_id ASC";
		
		$result = mysql_query($sql) OR die(mysql_error());
		
		if(!$result) {
		
		echo '<p class="false">' . $lang['no_categories'] . '.</p>';
		
			}else{
		
			if(intval(mysql_num_rows($result)) == 0) {
			
			echo '<strong>' . $lang['no_categories'] . '.</strong>';
		
		}else{
		
		echo '<table width="100%" cellpadding="5" class="cleantable">
		      <tr>
		      <td align="left" colspan="2"><strong>' . $lang['category'] . '</strong></td>
		      <td align="left"><strong>' . $lang['latest_topic'] . '</strong></td>
		      <td align="center"><strong>' . $lang['topics'] . '</strong></td>
		      </tr>';
		
		while($row = mysql_fetch_assoc($result)) {
		
		echo '<tr>
		      <td class="iconpart" valign="middle"><img src="images/category.png" alt="' . $lang['category'] . '"></td>
		      <td class="leftpart" valign="middle">
		      <span class="cat_head"><a href="category.php?id=' . (int)$row['cat_id'] . '" class="catline">' . htmlentities($row['cat_name'], ENT_QUOTES) . '</a></span><br>
              <span class="small_text">' . htmlentities($row['cat_description'], ENT_QUOTES) . '</span></td>
		
              <td class="rightpart">';
		
		$topicsql = "SELECT
						topics.topic_id,
						topics.topic_subject,
						topics.topic_date,
						topics.topic_cat,
						topics.topic_by,
						users.user_id,
						users.user_name
					 FROM
						topics
					 LEFT JOIN
						users
					 ON
						topics.topic_by = users.user_id
					 WHERE
						topic_cat = '" . (int)$row['cat_id'] . "'
					 ORDER BY
						topic_date DESC
					 LIMIT
						1";
		
		$topicsresult = mysql_query($topicsql) OR die(mysql_error());
		
		if(!$topicsresult) {
		
		echo '<strong>' . $lang['no_latest_topic'] . '.</strong>';
		
			}else{
		
			if(intval(mysql_num_rows($topicsresult)) == 0) {
			
			echo '<em>' . $lang['no_topics'] . '.</em>';
		
		}else{
		
		while($topicrow = mysql_fetch_assoc($topicsresult)) {
		
    		echo '<span class="cat_head"><a href="topic.php?id=' . (int)$topicrow['topic_id'] . '" class="forumtag">' . htmlentities($topicrow['topic_subject'], ENT_QUOTES) . '</a></span><br>
                  <span class="small_text"><strong>' . $lang['on_b'] . ':</strong> ';
            
                  if($language == "de") {
                      echo date('d.m.Y', strtotime($topicrow['topic_date']));
        
                  }elseif($language == "en") {
                      echo date('Y-m-d', strtotime($topicrow['topic_date'])); }
            
            echo '&nbsp;&nbsp;<strong>' . $lang['by_b'] . ':</strong> <a href="profile.php?user_id=' . (int)$topicrow['user_id'] . '" class="topicby">' . htmlentities($topicrow['user_name'], ENT_QUOTES) . '</a></span>';
		
        }}}
		
		echo '</td><td class="statpart" align="center">';
		
		$alltop = mysql_query("SELECT topic_id FROM topics WHERE topic_cat = " . (int)$row['cat_id'] . "");
		$topi = mysql_num_rows($alltop);
		
		echo '<div class="main_bubble">
    	  	  <span class="point2"></span>
    	  	  <span class="bubble2">' . (int)$topi . '</span>
		  	  </div></td>
			  </tr>';
		      }
        
        echo '</table>';
        }
        }
		
		?>

        <span class="cloud_button"><a href="top_topics.php" class="cloud_button"><?php echo $lang['top_topics']; ?></a></span>

		<div class="cloud_tags"><strong><?php
		
		$abfrage = mysql_query("SELECT cat_id FROM categories");
		$sum_categories = mysql_num_rows($abfrage);
		
        echo (int)$sum_categories;
		echo '</strong> ' . $lang['categories'] . ''; ?></div>
		<div class="cloud_tags"><strong><?php
		
		$abfrage = mysql_query("SELECT topic_id FROM topics");
		$sum_topics = mysql_num_rows($abfrage);
		
        echo (int)$sum_topics;
		echo '</strong> ' . $lang['topics'] . ''; ?></div>
		
		<div class="spacer_div">&nbsp;</div>
		
    </div>
</div>

<div id="infobox_wrapper">
    <div class="infobox">
        <?php include('layout/infobox.php'); ?>
    </div>
</div>

<?php require('layout/footer.php'); ?>
Return current item: WH Community