Hello to all. I have this function:


$p=intval($_GET['p']); if (empty($p)){ $p=1;//страница } // навигатор по страницам function pages ($p){ global $id; $res = mysql_query("select count(*) from news WHERE category=".$id."");// ищем все новости в категории $row = mysql_result($res,0); $news_num = "10"; $b = ceil(($row/$news_num)); // выводим по столько записей на страницу $x=1; while ($b>=$x){ if ($x==$p){ $news = mysql_query("select count(*) from news"); $pages_cat .= '<b>'.$x.'</b>'; } else { $pages_cat .= '&nbsp;<a href="/category/'.$id.'/'.$x.'/"><b>'.$x.'</b></a>&nbsp;'; } $x++; } return $pages_cat; } 

Tell me how to finish it, for example, let's say $ pages_cat output 20 pages each, then a line feed, again 20 pages and so on until all the records in the database are finished?

    1 answer 1

    Before $x++; insert:

      if ($x % 20 == 0) { $pages_cat .= '<br/>'; } 
    • Thank. Another question, how to make the current page on which the user is not a hyperlink? - Alexander Podgorny
    • $ p is needed to contain the current page. Something like this: <a href="/category/'.$id.'/?p='.$x.'"><b>'.$x.'</b></a> then $p=intval($_GET['p']) will contain the current page. Well, or if you use mod_rewrite, then you need to bring the url to this form, so that there is a variable p in _GET ... - Yura Ivanov
    • Thanks, but I know that. I use mod_rewrite. just the script is already transferred the value of the page, it is on it and looks for and displays the news. And how did I not think of how to specify and output another in the script)) Can you help with more tips =) Do you have an agent or an agent? - Alexander Podgorny
    • so it should be displayed $pages_cat .= '<b>'.$x.'</b>'; just displays the current page number in the list, without a link. Threat with php familiarly, glad that I could help here, on other issues I can hardly ...) - Yura Ivanov
    • Well, well))) So it helped. And what's the big deal in TV is that he doesn't want to print $ pages_cat. = '<B>'. $ X. '</ B>'; personally writes the void and still need to somehow exclude the value of x from the output, that is, without reference - Alexander Podgorny