View file board/includes/my.php

File size: 1.91Kb
<?php
/**
 * Created by PhpStorm.
 * User: Valeriy Shikuta aka Str@nnik
 * Date: 15.02.2016
 * Time: 18:16
 * File: my.php
 * ICQ: 609-745-227
 * E-mail: [email protected]
 */

if ($id)
{
    echo '<div class="phdr">Объявления</div>';

    $total = mysql_result(mysql_query("SELECT COUNT(*) FROM `board_ads` WHERE `user_id` = $id AND `status` = 1"), 0);
    if ($total)
    {
        $req = mysql_query("SELECT * FROM `board_ads` WHERE `user_id` = $id AND `status` = 1 ORDER BY `time` DESC LIMIT $start, $kmess");
        $i = 0;
        while ($res = mysql_fetch_assoc($req))
        {
            echo ($i % 2) ? '<div class="list1">' : '<div class="list2">';
            if (time() > $res['end']) mysql_query("UPDATE `board_ads` SET `status` = 2 WHERE `id` = " . $res['id'] . "");
            echo (!empty($res['img'])) ? '<img src="../images/board/small/' . $res['img'] . '.png" align="middle" alt="' . $res['img'] . '">' : '<img src="../images/no_board.png" width="25" height="25" align="middle" alt="' . $res['img'] . '">';
            echo '&nbsp;<a href="./?act=view&amp;id=' . $res['id'] . '">' . $res['name'] . '</a>'
                . '</div>';
            $i++;
        }
    }
    else
    {
        echo '<div class="menu">У юзера нету активных объявлений</div>';
    }
    echo '<div class="phdr">Всего:&nbsp;' . $total . '</div>';

    if ($total > $kmess)
        echo '<div class="topmenu">' . functions::display_pagination('./?act=my&amp;id=' . $id . '&amp;', $start, $total, $kmess) . '</div>';

    $archive = mysql_result(mysql_query("SELECT COUNT(*) FROM `board_ads` WHERE `user_id` = $id AND`status` = 2"), 0);
    echo ($archive) ? '<div class="rmenu"><img src="../images/del.png" alt="archive">&nbsp;<a href="./?act=archive&amp;id=' . $id . '">В архиве</a>&nbsp;[' . $archive . ']</div>' : null;
}
else
{
    header('location: ./');
}