<?php require('style/layout/header.php'); ?>
<div class="content_left">
<ul id="breadcrumbs">
<li><a href="index.php"><?php echo $lang['main_page']; ?></a></li>
<li><a href="all_categories.php" class="actual"><?php echo $lang['all_categories']; ?></a></li>
</ul>
</div>
<div class="content_right"><form method="post" id="search" action="search.php?search">
<input type="text" name="search" placeholder="<?php echo $lang['enter_search_term']; ?>..." class="searchfield">
<input type="hidden" name="submit" value="<?php echo $lang['search']; ?>" alt="<?php echo $lang['search']; ?>">
</form>
</div>
<div class="clear"></div>
<div id="headline"> </div>
<?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>' . mysql_error();
}else{
if(intval(mysql_num_rows($result)) == 0) {
echo '<p class="false">' . $lang['no_categories'] . '</p>';
}else{
echo '<table width="100%" class="tables">
<tr>
<td align="left"><span class="dark">' . $lang['one_category'] . '</span></td>
<td align="left"><span class="dark">' . $lang['last_topic'] . '</span></td>
<td align="center"><span class="dark">' . $lang['blank_topics'] . '</span></td>
</tr>';
while($row = mysql_fetch_assoc($result)) {
echo '<tr>
<td width="62%" align="left"><a href="category.php?id=' . (int)$row['cat_id'] . '" class="cat_head">' . htmlentities($row['cat_name'], ENT_QUOTES) . '</a><br><br>
<span class="category_description">' . stripslashes($row['cat_description']) . '</span></td>';
$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());
echo '<td width="30%" align="left">';
if(!$topicsresult) {
echo '<em>' . $lang['no_available_topics'] . '</em>' . mysql_error();
}else{
if(intval(mysql_num_rows($topicsresult)) == 0) {
echo '<em>' . $lang['no_available_topics'] . '</em>';
}else{
while($topicrow = mysql_fetch_assoc($topicsresult)) {
echo '<a href="topic.php?id=' . (int)$topicrow['topic_id'] . '" class="topic_head">' . htmlentities($topicrow['topic_subject'], ENT_QUOTES) . '</a><br><br>
<span class="category_description"><strong>' . $lang['on'] . ':</strong> ' . date('d.m.Y', strtotime($topicrow['topic_date'])) . '
<strong>' . $lang['by'] . ':</strong> <a href="profile.php?user_id=' . (int)$topicrow['user_id'] . '" class="topicby">' . htmlentities($topicrow['user_name'], ENT_QUOTES) . '</a></span>';
}
}
}
echo '</td><td width="8%" align="center">';
$count_topics = mysql_query("SELECT topic_id FROM topics WHERE topic_cat = " . (int)$row['cat_id'] . "");
$result_topics = mysql_num_rows($count_topics);
echo '<div class="bubble"><span class="bubpoint"></span><span class="bubcon">' . (int)$result_topics . '</span></div></td></tr>';
}
echo '</table>';
echo '<a href="feeds/topic_rss.php" target="_blank" class="feeds des rss">RSS ' . $lang['blank_topics'] . '</a>';
}
}
?>
<?php require('style/layout/footer.php'); ?>