<?php

$k_post = mysql_result(mysql_query("SELECT COUNT(*) FROM `diary` WHERE `name` like '%" . mysql_real_escape_string($search_text) . "%' OR `name` like '%" . translit($search_text) . "%' OR `name` like '%" . retranslit($search_text) . "%' OR `msg` like '%" . $search_text . "%' OR `msg` like '%" . translit($search_text) . "%' OR `msg` like '%" . retranslit($search_text) . "%'"), 0);
$k_page = k_page($k_post, $set['p_str']);
$page = page($k_page);
$start = $set['p_str'] * $page - $set['p_str'];
$q = mysql_query("SELECT * FROM `diary` WHERE `name` like '%" . mysql_real_escape_string($search_text) . "%' OR	`name` like '%" . translit($search_text) . "%' OR `name` like '%" . retranslit($search_text) . "%' OR `msg` like '%" . $search_text . "%' OR `msg` like '%" . translit($search_text) . "%' OR `msg` like '%" . retranslit($search_text) . "%' ORDER BY `id` DESC LIMIT $start, $set[p_str]");

if ($k_post == 0) {
    $doc->NoResult();
}

while ($post = mysql_fetch_assoc($q)) {
    $us = get_user($post['id_user']);

    echo '<div class="list-group-item-null">';
    echo "<a href='/modules/diary/$post[name]/'><i class='fa fa-book fa-fw'></i> $post[name]</a> <small style='color: grey;'>" . date::time($post['time']) . "</small><br />";

    echo '<i class="fa fa-eye fa-fw"></i> Просмотров: ' . $post['viewings'] . ' | ';
    echo '<i class="fa fa-star fa-fw"></i> Рейтинг: ' . $post['rating'] . '<br/>';

    echo '</div>';
    echo "<div class='hr'></div>";
}

if ($k_page > 1) {
    str("?search=people&amp;", $k_page, $page);
}
