Файл: mlord.ru/admin/section.php
Строк: 57
<?
require_once('../core/index.php');
require_once('../core/func.php');
admin(2);
$title='Категории форума';
require_once('../design/head.php');
$count=$db->query("SELECT id FROM `section`")->rowCount();
if($count==0){echo '<div class="h2">Вещей нет.</div>';}
require '../core/pagination.php';
$pagination = new Pagination;
$pagination->sett($count, 10, true);
$res = $db->query("SELECT * FROM `section` " . $pagination->limit());
$num=1;
foreach($res as $section){
$count_them=$db->query("SELECT id FROM `them` where `section`='".$section['id']."'")->rowCount();
echo '<div class="h2"><b>'.$num.')</b> '.$section['name'].'<br/>
Уровень: '.$section['lvl'].' <br/>
Тем: '.$count_them.' <br/>
<a href=/admin/section/change/'.$section['id'].'>[ред]</a> | <a href=?delete&id='.$section['id'].'>[уд]</a>
</div>';
++$num;
}
echo $pagination->get();
if(isset($_GET['delete']) && isset($_GET['id'])){
$count=$db->query("SELECT id FROM `section` WHERE `id`='".$_GET['id']."'")->rowCount();
if($count==0){$_SESSION['msg']='Вещи не существует'; header('Location:?'); exit();}
$db->exec("DELETE FROM `section` WHERE `id`='".$_GET['id']."'");
$db->exec("DELETE FROM `them` WHERE `section`='".$_GET['id']."'");
$_SESSION['msg']='Удалено'; header('Location:?');
}
echo '<div class="h2"><a href=/admin/section/create>Создать категорию</a></div>';
echo '<div class="h2"><a href=/admin/>Адм. панель</a></div>';
require_once('../design/foot.php');
?>