您好我的问题如下:我已经根据结果页面进行了划分..问题是afiserea结果我有以下代码:
<?php
include('ttt_files/paginare.php');
$rezultate_pe_pagina = '2';
$statement = "`anunt_standard` where `activat` = 0 AND prs_prv='$filtru_p' ";
/* Inceputul stabiliri functiei numaratorelor */
$page = (int) (!isset($_GET["page"]) ? 1 : $_GET["page"]);
$limit = $rezultate_pe_pagina;
$startpoint = ($page * $limit) - $limit;
//Query pentru afisere si paginare
/* Sfarsitul stabiliri functiei numaratorelor */
$url = "{$server_url}anunturi/f/{$_GET['f']}/page/";
echo "<div id='asezare_butoane'>".pagination($statement,$limit,$page,$url)."</div>";
//afiseaza inregistrarile platite
$query_pay = mysql_query("
SELECT * FROM {$statement} AND activat_plata = '1'
AND sters = '0' ORDER BY data_adaugare DESC LIMIT {$startpoint} ,
{$limit}");
echo "
<table border='0' width='950px'
style='border-collapse:separate; border-spacing:0px 5px;'>";
$i = 0;
while ($row = mysql_fetch_assoc($query_pay)) {
include('continut_platit.php');
}
echo "</table>";
//afiseaza inregistrarile normale
$query = mysql_query("
SELECT * FROM {$statement} AND sters = '0'
AND activat_plata = '0'
ORDER BY data_adaugare DESC
LIMIT {$startpoint} , {$limit}");
echo "
<table border='0' width='950px'
style='border-collapse:separate; border-spacing:0px 5px;'>";
$i = 0;
while ($row = mysql_fetch_assoc($query)) {
include('continut.php');
}
echo "</table>";
//afiseaza inregistrarile sterse
$query_del = mysql_query("
SELECT * FROM {$statement}
AND sters = '1'
ORDER BY data_adaugare DESC
LIMIT {$startpoint} , {$limit}");
echo "<table border='0' width='950px' style='border-collapse:separate; border-spacing:0px 5px;'>";
$i = 0;
while ($row = mysql_fetch_assoc($query_del)) {
include('continut_sters.php');
}
echo "</table>";
?>
问题是它不显示每页 2 个结果,因为它现在设置显示每个查询的结果 2 即粘贴总共 6 个结果: 2 - $ query_pay 2 - $ query 2 - $ query_del 但是请弄清楚如何制作它仅显示 2 例如如果添加 2 条记录“支付”以仅在这 2 条上显示,则为第一页。或者如果您只有 2 条记录,则查询仅显示那 2 条:(分页功能
<?php
function pagination($query, $per_page = 10,$page = 1, $url = '?'){
$query = "SELECT COUNT(*) as `num` FROM {$query}";
$row = mysql_fetch_array(mysql_query($query));
$total = $row['num'];
$adjacents = "2";
$page = ($page == 0 ? 1 : $page);
$start = ($page - 1) * $per_page;
$prev = $page - 1;
$next = $page + 1;
$lastpage = ceil($total/$per_page);
$lpm1 = $lastpage - 1;
$pagination = "";
if($lastpage > 1)
{
$pagination .= "<ul class='pagination'>";
//$pagination .= "<li class='details'>Pagina $page din $lastpage</li>";
if ($lastpage < 7 + ($adjacents * 2))
{
for ($counter = 1; $counter <= $lastpage; $counter++)
{
if ($counter == $page)
$pagination.= "<li><a class='current'>$counter</a></li>";
else
$pagination.= "<li><a href='{$url}$counter/'>$counter</a></li>";
}
}
elseif($lastpage > 5 + ($adjacents * 2))
{
if($page < 1 + ($adjacents * 2))
{
for ($counter = 1; $counter < 4 + ($adjacents * 2); $counter++)
{
if ($counter == $page)
$pagination.= "<li><a class='current'>$counter</a></li>";
else
$pagination.= "<li><a href='{$url}$counter/'>$counter</a></li>";
}
$pagination.= "<li class='dot'>...</li>";
$pagination.= "<li><a href='{$url}$lpm1/'>$lpm1</a></li>";
$pagination.= "<li><a href='{$url}$lastpage/'>$lastpage</a></li>";
}
elseif($lastpage - ($adjacents * 2) > $page && $page > ($adjacents * 2))
{
$pagination.= "<li><a href='{$url}1/'>1</a></li>";
$pagination.= "<li><a href='{$url}2/'>2</a></li>";
$pagination.= "<li class='dot'>...</li>";
for ($counter = $page - $adjacents; $counter <= $page + $adjacents; $counter++)
{
if ($counter == $page)
$pagination.= "<li><a class='current'>$counter</a></li>";
else
$pagination.= "<li><a href='{$url}$counter/'>$counter</a></li>";
}
$pagination.= "<li class='dot'>..</li>";
$pagination.= "<li><a href='{$url}$lpm1/'>$lpm1</a></li>";
$pagination.= "<li><a href='{$url}$lastpage/'>$lastpage</a></li>";
}
else
{
$pagination.= "<li><a href='{$url}1/'>1</a></li>";
$pagination.= "<li><a href='{$url}2/'>2</a></li>";
$pagination.= "<li class='dot'>..</li>";
for ($counter = $lastpage - (2 + ($adjacents * 2)); $counter <= $lastpage; $counter++)
{
if ($counter == $page)
$pagination.= "<li><a class='current'>$counter</a></li>";
else
$pagination.= "<li><a href='{$url}$counter/'>$counter</a></li>";
}
}
}
if ($page < $counter - 1){
$pagination.= "<li><a href='{$url}$next/'>Urmatoarea</a></li>";
//$pagination.= "<li><a href='{$url}page=$lastpage'>Ultima</a></li>";
}else{
$pagination.= "<li><a class='current'>Urmatoarea</a></li>";
//$pagination.= "<li><a class='current'>Ultima</a></li>";
}
$pagination.= "</ul>\n";
}
return $pagination;
}
?>
I thought to count total results above and to create a condition that is nustiu posters but how to put condition. Or to put the 3 above the query results and number then I gather and share their work at 3:01 so? But go to a function and not know how to think
mysql_query("SELECT u.* FROM (
(SELECT * FROM anunt_standard WHERE `activat_plata`='1' AND `sters`='0' AND `activat`='0' ORDER BY data_adaugare DESC)
UNION
(SELECT * FROM anunt_standard WHERE `activat_plata`='0' AND `sters`='0' AND `activat`='0' ORDER BY data_adaugare DESC)
UNION
(SELECT * FROM anunt_standard WHERE `sters`='1' AND `activat`='0' ORDER BY data_adaugare DESC)
) As u LIMIT {$startpoint} , {$limit}")or die(mysql_error());
Thanks for the idea but the problem is that they fail to display in the order you want ... I mean nothing I write:
ORDER BY data_adaugare DESC