Answer the question
In order to leave comments, you need to log in
Why is it displayed in the user part, but not in the admin panel?
Action
<?php
if(!$user) {
$text = "ACCESS DENIED";
$content = render(TEMPLATE."admin/error.tpl",array(
));
}
if(can($user['id_role'],array("MODER_MESS","RETIME_MESS"))) {
if($_GET['page']) {
$page = (int)$_GET['page'];
if(!$page) {
$page = 1;
}
}
else {
$page = 1;
}
$count_mess = count_nc_mess();
$text = get_nc_mess($page,PERPAGE);
$navigation = get_navigation($page,$count_mess,PERPAGE);
}
$content = render(TEMPLATE."admin/admin_home.tpl",array(
'text' => $text,
'navigation' => $navigation,
'page' => $page
));
?>
function count_nc_mess()
{
global $db;
$sql = "SELECT COUNT(*) AS count FROM " . PREF . "post WHERE confirm = '0'";
$result = mysqli_query($db, $sql);
$row = get_result($result);
return $row[0]['count'];
}
function get_nc_mess($page, $perpage)
{
global $db;
$start = ($page - 1) * $perpage;
$sql = "SELECT
" . PREF . "post.id,
" . PREF . "post.title,
" . PREF . "users.name AS uname,
" . PREF . "users.email,
" . PREF . "categories.name AS cat,
" . PREF . "razd.name AS razd
FROM " . PREF . "post
LEFT JOIN " . PREF . "users ON " . PREF . "users.user_id = " . PREF . "post.id_user
LEFT JOIN " . PREF . "categories ON " . PREF . "categories.id = " . PREF . "post.id_categories
LEFT JOIN " . PREF . "razd ON " . PREF . "razd.id = " . PREF . "post.id_razd
WHERE " . PREF . "post.confirm = '0'";
$sql .= "ORDER by date DESC";
$sql .= " LIMIT $start,$perpage";
$result = mysqli_query($db, $sql);
return get_result($result);
}
<h3 class="title_page">Не подтвержденные объявления</h3>
<form method="POST">
<table cellspacing="0" class="moder_mess">
<thead>
<th>id</th>
<th>title</th>
<th>User</th>
<th>Action</th>
</thead>
<? if (is_array($text)) : ?>
<? foreach ($text as $item) : ?>
<tr>
<td>
<?= $item['id']; ?>
</td>
<td>
<?= $item['title']; ?> <br/>
<small><?= $item['cat']; ?></small>
|
<small><?= $item['razd']; ?></small>
</td>
<td>
<?= $item['user']; ?> <br/>
<?= $item['email']; ?>
</td>
<td>
<input type="checkbox" name="id_mess[]" value="<?= $item['id']; ?>">
</td>
</tr>
<? endforeach; ?>
<? endif; ?>
</table>
<input type="submit" value="Ok"/>
</form>
<p>Не подтвержденных объявлений нет</p>
<? if ($navigation) : ?>
<ul class="pager">
<? if ($navigation['first']) : ?>
<li class="first">
<a href="?page=1">Первая</a>
</li>
<? endif; ?>
<? if ($navigation['last_page']) : ?>
<li>
<a href="?page=<?= $navigation['last_page'] ?>"><</a>
</li>
<? endif; ?>
<? if ($navigation['previous']) : ?>
<? foreach ($navigation['previous'] as $val) : ?>
<li>
<a href="?page=<?= $val; ?>"><?= $val; ?></a>
</li>
<? endforeach; ?>
<? endif; ?>
<? if ($navigation['current']) : ?>
<li>
<span><?= $navigation['current']; ?></span>
</li>
<? endif; ?>
<? if ($navigation['next']) : ?>
<? foreach ($navigation['next'] as $v) : ?>
<li>
<a href="?page=<?= $v; ?>"><?= $v; ?></a>
</li>
<? endforeach; ?>
<? endif; ?>
<? if ($navigation['next_pages']) : ?>
<li>
<a href="?page=<?= $navigation['next_pages'] ?>">></a>
</li>
<? endif; ?>
<? if ($navigation['end']) : ?>
<li class="last">
<a href="?page=<?= $navigation['end'] ?>">Последняя</a>
</li>
<? endif; ?>
</ul>
<? endif; ?>
Answer the question
In order to leave comments, you need to log in
Use var_dump or install xdebug and see what is the difference between working in the user part and in the admin panel
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question