<?
include '../config.php';
include '../func.php';

head();
aut();
ban();

echo head . 'Микроблог' . div . katalog;

switch ($_GET['mod']) {
    
    default:
    $all = mysql_result(mysql_query("SELECT count(*) FROM `microblog`"), 0);
    if($all){
    $onpage = 10;
    $allpage = ceil($all/$onpage);
    $this_page = (isset($_GET['p'])) ? intval($_GET['p']) : 1 ;
    if($this_page < 1 || $this_page > $allpage)$this_page = 1;
    $start = $this_page*$onpage - $onpage;
    $result = mysql_query("SELECT * FROM `microblog` ORDER BY `id` DESC limit ".num($start).",".num($onpage)."");
    while($blog = mysql_fetch_assoc($result)){
        echo "<img src=\"../style/".$icon."/dot.gif\" alt=\"\" /> <a href='../microblog/blog.php?id=$blog[id]'>".$blog[name]."...</a> <b>".user($blog[id_user])."</b> [<a href='microblog.php?id=$blog[id]&mod=delete'>x]</a><br/>"; 
    
    }
    echo link1 . '<b>Страницы:</b> ';
    navigation($allpage,"microblog.php?p={p}",1,1);
    echo div;
    }
    break;
    
    case 'delete':
    $id = num($_GET['id']);
    $p = num($_GET['p']);
    mysql_query("DELETE FROM `microblog` WHERE `id` = '".$id."'");
    header('Location: microblog.php?p='.$p);
    break;
}
////////////////////////////////////////////////////////////////////////////////
navig();
foot();