<?php
session_start();
ob_start();
?>
<?php
include ('header_forum.php');
include ('connect.php');
?>
<br/>
<?php
$temaid = $_GET['id'];
if ($temaid == NULL) {
?>
<div style="background-color: black; width: 864px;">
<center><p class="typ">Нова Тема</p> </center>
<center>
<table width="864px" border-color="black">
<tr>
<td width="15%" class="forum2"><center><img src="images/forum/shadow.jpg" alt="" /></center></td>
<td width="85%" class="forum2" valign="top"><br/>
<b class="typ1" style="margin-left: 20px;">Няма такава тема!</a><br/></td>
</tr>
</table>
</div>
<?php
}else{
$quera = "SELECT * FROM forum_temi WHERE id = '$temaid'";
$result = MYSQL_QUERY($quera)or die(mysql_error());
$i = 0;
$zaglavie = mysql_result($result,$i,"zaglavie");
$forumid = mysql_result($result,$i,"forum");
$querb = "SELECT * FROM forum_forumi WHERE id = '$forumid'";
$resulta = MYSQL_QUERY($querb)or die(mysql_error());
$i = 0;
$imeforum = mysql_result($resulta,$i,"ime");
$avtor = mysql_result($result,$i,"avtor");
$gyz1 = mysql_result($result, $i, "data");
$data1 = date(" d\.M\.Y", $gyz1);
?>
<table width="867px">
<tr>
<td width="867px" class="forum" align="left"><a class="typ1" align="left" href="index_forum.php"> ForDotA.Com Форум</a><b class="idiot"> -></b><a class="typ1" align="left" href="forumview.php?id=<?php echo "$forumid"; ?>"> <?php echo "$imeforum"; ?></a><b class="idiot"> -></b><a class="typ1" align="left" href="viewtema.php?id=<?php echo "$temaid"; ?>"> <?php echo "$zaglavie"; ?></a></td>
</tr>
</table>
<div style="background-color: black; width: 864px;">
<table width="865px">
<tr>
<td width="865px" class="forum2" align="center"><b style="font-size: 17px; color: black;"><?php echo "$zaglavie"; ?></b></td>
</tr>
</table>
<table width="865px">
<tr>
<td width="216px" class="forum2" align="center"><b style="font-size: 15px; color: black;"><?php echo "Автор"; ?></b></td>
<td width="648px" class="forum2" align="center"><b style="font-size: 15px; color: black;"><?php echo "Текст"; ?></b></td>
</tr>
</table>
<?php
//server connfigure
$table_name = "forum_saob6teniq";
//server connfigure
//колко резултата на страница
$pp = "20";
//колко резултата на страница
$page=$_GET['page']; //присвояваме стойността на page
if(!$_GET['page']) //ако не е взета page да върне 1-ца
{
$page="1";
}
$limit = ($pp*$page)-$pp; //определяме лимитирането
$redove=mysql_query("SELECT * FROM $table_name");
$max= mysql_numrows($redove); //преброяваме редовете
$total=ceil($max/$pp); //пресмятаме броя на страниците
$dupe = mysql_query("SELECT * FROM forum_saob6teniq ORDER BY id ASC LIMIT $limit,$pp")or die(mysql_error());
$numa = mysql_num_rows($dupe);
for ($i=0;$i<$numa;$i++) {
$avtora = mysql_result($dupe,$i,"avtor");
$texta = mysql_result($dupe,$i,"Text");
$data2 = mysql_result($dupe,$i,"data");
$data = date("H:i:s, d.m.Y", $data2);
$querc = "SELECT * FROM users WHERE username = '$avtora'";
$resultc = MYSQL_QUERY($querc)or die(mysql_error());
echo '
<table width="865px">
<tr>
<td valign="top" rowspan="2" width="216px" class="forum2" align="center">
';
$avatar = mysql_result($resultc,$i,"avatar");
$avtorid = mysql_result($resultc,$i,"id");
$penio = mysql_num_rows($resultc);
$postove = mysql_result(mysql_query("SELECT count(id) FROM forum_saob6teniq WHERE avtor = '$avtor' "), 0, 0);
echo '
<a href="profile.php?user='.$avtora.'" class="typ1">'.$avtora.'</a><br/><br/>
<img src="'.$avatar.'" width="150px" style="border: 3px solid black;" height="150px" alt="avatar" />
<br/>
';
echo '
<b class="typ1">Мнения: '.$postove.'</b>
</td>
<td valign="top" height="100%" width="648px" style="padding-left: 4px; overflow: hidden;" class="forum2" align="left">
<p class="forum">'.$texta.'</p>
<br/><br/>
<br/><br/><br/>
</td>
</tr>
<tr>
<td class="forum2" align="right" class="overflow: hidden;" height="1px"><b class="typ1">Написано на '.$data.'</b></td>
</tr>
</table>
';
}
?>
</div>
<?php
}
?>
<br/>
<?php
include ('footer_forum.php');
?>