Пусто странициране, немога да се оправя и това си е...

porostorm

Registered
Четох уроците за странициране, четох ... ма нищо немога да разбера :cry: Ето ми го кода за точене на "новини" от форума, как ще стане пустото странициране :cry:
Код:
<?php

$broi_bukvi="70";			 // do kolko bukvi v zaglaviqta na novinite
$limit = '10';				 // How many topics to show	
$show = 'full';				// How to show the topics? full or blank ('')
$date_time = 'long';			// How to display the date and time if used? short or long
$topic_link = 'topic';			// How top display the topic link if usede? topic or phpbb
$comment = 'topic';			// Comments link - how to send them to comments? topic or reply
$phpbb_root_path = 'forum/';		// Path to your forums directory

if ( !defined('IN_PHPBB') )
{
define('IN_PHPBB', true);
include($phpbb_root_path . 'extension.inc');
include($phpbb_root_path . 'common.'.$phpEx);
include($phpbb_root_path . 'config.'.$phpEx);
}
if ($show == '' || $show == 'full')
{
// Select the topic information from the correct forum and set it to $grab_topics
$grab_topics = $db->sql_query("SELECT * FROM `{$table_prefix}topics` WHERE `forum_id` = '{$forum}' ORDER BY `topic_id` DESC LIMIT {$limit}");
}
else if ($show == 'topic')
{
$grab_topics = $db->sql_query("SELECT * FROM `{$table_prefix}topics` WHERE `forum_id` = '{$forum}' AND `topic_id` = '{$_GET['t']}' ORDER BY `topic_id` DESC");
}
// Grab the information using an array and set it to $echo_topic
while ($echo_topic = $db->sql_fetchrow($grab_topics))
{
// Select the post information from the correct forum and set it to $grab_posts
$grab_posts = $db->sql_query("SELECT * FROM `{$table_prefix}posts` WHERE `forum_id` = '{$forum}' AND `topic_id` = '{$echo_topic['topic_id']}' LIMIT 1");
// Grab the information using an array and set it to $echo_post
while ($echo_post = $db->sql_fetchrow($grab_posts))
{
// Now get the post_text using the post_id were looking at and sort it info $grab_posts_text
$grab_posts_text = $db->sql_query("SELECT * FROM `{$table_prefix}posts_text` WHERE `post_id` = '{$echo_post['post_id']}'");
// Grab the information using an array and set it to $echo_text
while($echo_text = $db->sql_fetchrow($grab_posts_text))
{
// Find the user the posted
$find_user = $db->sql_query("SELECT * FROM `{$table_prefix}users` WHERE `user_id` = '{$echo_post['poster_id']}'");
// Sort this users info into array for the post
while ($echo_user = $db->sql_fetchrow($find_user))
{
// Get rid of all those annoying characters from bbcode
$echo_text = preg_replace('/\:[0-9a-z\:]+\]/si', ']', $echo_text);   
             
            $echo_text = str_replace("[b]","<strong>",$echo_text);   
            $echo_text = str_replace("[/b]","</strong>",$echo_text);  
            
            $echo_text = str_replace("[i]","<em>",$echo_text);   
            $echo_text = str_replace("[/i]","</em>",$echo_text);   
                   
            $echo_text = str_replace("[u]","<u>",$echo_text);   
            $echo_text = str_replace("[/u]","</u>",$echo_text);   
                   
  	    $echo_text=preg_replace("/\[size\=(.+?)\](.+?)\[\/size\]/s","<font size=\"$1\">$2</font>",$echo_text); 
	    $echo_text=preg_replace("/\[color\=(.+?)\](.+?)\[\/color\]/s","<font color=\"$1\">$2</font>",$echo_text);
              
            $echo_text = str_replace("[quote]","<small><b>Цитат:</b></small><table border=\"0\" width=\"0\" id=\"table1\" style=\"border-style: dotted; border-width: 2px; padding: 0\"><tr><td>",$echo_text);   
            $echo_text = str_replace("[/quote]","</td></tr></table>",$echo_text);   
                   
   	    $echo_text=preg_replace("/\[code\](.+?)\[\/code\]/s","<small><b>Код:</b></small><table border=\"0\" width=\"0\" id=\"table1\" style=\"border-style: dotted; border-width: 2px; padding: 0\"><tr><td>$1</td></tr></table>",$echo_text);       
                   
            $echo_text = str_replace("[img]","<img border=\"0\" src=\"",$echo_text);   
            $echo_text = str_replace("[/img]","\" alt=\"image\" />",$echo_text);   
                   
	    $echo_text = preg_replace('/\[url\](.*)\[\/url\]/Usi','<a class="gensmall" target="_blank" href="$1">$1</a>',$echo_text);
	    $echo_text = preg_replace('/\[url=(.*)\](.*)\[\/url\]/Usi','<a class="gensmall" target="_blank" href="$1">$2</a>',$echo_text);
                 
	    $echo_text = preg_replace('/\[list\](.*)\[\/list\]/si',"<center>$1</center>",$echo_text);
	    $echo_text = preg_replace('/\[list=(.*)\](.*)\[\/list\]/si',"<center>$1</center>",$echo_text);
  
            $echo_text = str_replace("\n", "\n<br />\n", $echo_text); 

if($date_time == "long")		// Way to display date and time? long
{
$echo_topic['topic_time'] = strftime("%A %e %B %H:%M",$echo_topic['topic_time']);
}
// Way to display comment link
// Go right to the topic
if ($comment == 'topic')
{
$comment_link = "{$phpbb_root_path}viewtopic.php?t={$echo_topic['topic_id']}";
}

// This link goes to the actual phpbb topic
if ($topic_link == 'phpbb')
{
$topic_link = "{$phpbb_root_path}viewtopic.php?t={$echo_topic['topic_id']}";
}

##################################
## Edit for look and feel of topic
##################################
// Display many topics - for news, shoutbox etc
else if ($show == 'full')
{
if (strlen($echo_text['post_subject'])>$broi_bukvi)
{$totchki='...';}
else
{$totchki='';}
$echo_text['post_subject']=substr($echo_text['post_subject'],0 , $broi_bukvi);
echo "<table class=\"forumline\" border=\"0\" cellpadding=\"2\" cellspacing=\"1\" width=\"100%\"><tbody><tr><td class=\"rowpic\" align=\"left\" valign=\"top\" style=\"background-color: #F0F0F0\"><img src=\"index.php_files/news.gif\" alt=\"news\" /> <font size='1'><b><a class='gensmall' href=\"{$comment_link}\" target=\"_blank\">{$echo_text['post_subject']}$totchki</a></b></font></td></tr></tbody></table><table class=\"forumline\" border=\"0\" cellpadding=\"2\" cellspacing=\"1\" width=\"100%\"><tbody><tr><td class=\"rowpic\" align=\"justify\" valign=\"top\" style=\"background-color: #F3F3F3\">{$echo_text['post_text']}</td></tr></tbody></table><table class=\"forumline\" border=\"0\" cellpadding=\"2\" cellspacing=\"1\" width=\"100%\"><tbody><tr><td class=\"rowpic\" align=\"left\" valign=\"top\" style=\"background-color: #F3F3F3\">Написано на: {$echo_topic['topic_time']} | Коментари: <a class='gensmall' href=\"{$comment_link}\" target=\"_blank\">{$echo_topic['topic_replies']}</a> | Автор: <a class='gensmall' href=\"".$phpbb_root_path."profile.php?mode=viewprofile&u={$echo_user['user_id']}\" target=\"_blank\">{$echo_user['username']}</a></td></tr></tbody></table>";
echo "<br />";
}
}
}
}
}
?>
Кода е доста, но повечето е украса. Благодаря на отзовалите се :roll:
 
Така?

Код:
<?php

$page=$_GET['page'];

if(!$_GET['page'])
{
$page="1";
}

$pp = "10"; //колко на страница

$limit = ($pp*$page)-$pp;

$broi_bukvi="70";          // do kolko bukvi v zaglaviqta na novinite  
$show = 'full';            // How to show the topics? full or blank ('')
$date_time = 'long';         // How to display the date and time if used? short or long
$topic_link = 'topic';         // How top display the topic link if usede? topic or phpbb
$comment = 'topic';         // Comments link - how to send them to comments? topic or reply
$phpbb_root_path = 'forum/';      // Path to your forums directory

if ( !defined('IN_PHPBB') )
{
define('IN_PHPBB', true);
include($phpbb_root_path . 'extension.inc');
include($phpbb_root_path . 'common.'.$phpEx);
include($phpbb_root_path . 'config.'.$phpEx);
}
if ($show == '' || $show == 'full')
{
// Select the topic information from the correct forum and set it to $grab_topics
$grab = $db->sql_query("SELECT * FROM `{$table_prefix}topics` WHERE `forum_id` = '{$forum}'");
$max=mysql_numrows($grab);
$total=ceil($max/$pp);
$grab_topics = $db->sql_query("SELECT * FROM `{$table_prefix}topics` WHERE `forum_id` = '{$forum}' ORDER BY `topic_id` DESC LIMIT $limit,$pp");
}
else if ($show == 'topic')
{
$grab_topics = $db->sql_query("SELECT * FROM `{$table_prefix}topics` WHERE `forum_id` = '{$forum}' AND `topic_id` = '{$_GET['t']}' ORDER BY `topic_id` DESC");
}
// Grab the information using an array and set it to $echo_topic
while ($echo_topic = $db->sql_fetchrow($grab_topics))
{
// Select the post information from the correct forum and set it to $grab_posts
$grab_posts = $db->sql_query("SELECT * FROM `{$table_prefix}posts` WHERE `forum_id` = '{$forum}' AND `topic_id` = '{$echo_topic['topic_id']}' LIMIT 1");
// Grab the information using an array and set it to $echo_post
while ($echo_post = $db->sql_fetchrow($grab_posts))
{
// Now get the post_text using the post_id were looking at and sort it info $grab_posts_text
$grab_posts_text = $db->sql_query("SELECT * FROM `{$table_prefix}posts_text` WHERE `post_id` = '{$echo_post['post_id']}'");
// Grab the information using an array and set it to $echo_text
while($echo_text = $db->sql_fetchrow($grab_posts_text))
{
// Find the user the posted
$find_user = $db->sql_query("SELECT * FROM `{$table_prefix}users` WHERE `user_id` = '{$echo_post['poster_id']}'");
// Sort this users info into array for the post
while ($echo_user = $db->sql_fetchrow($find_user))
{
// Get rid of all those annoying characters from bbcode
$echo_text = preg_replace('/\:[0-9a-z\:]+\]/si', ']', $echo_text);   
             
            $echo_text = str_replace("[b]","<strong>",$echo_text);   
            $echo_text = str_replace("[/b]","</strong>",$echo_text); 
           
            $echo_text = str_replace("[i]","<em>",$echo_text);   
            $echo_text = str_replace("[/i]","</em>",$echo_text);   
                   
            $echo_text = str_replace("[u]","<u>",$echo_text);   
            $echo_text = str_replace("[/u]","</u>",$echo_text);   
                   
         $echo_text=preg_replace("/\[size\=(.+?)\](.+?)\[\/size\]/s","<font size=\"$1\">$2</font>",$echo_text);
       $echo_text=preg_replace("/\[color\=(.+?)\](.+?)\[\/color\]/s","<font color=\"$1\">$2</font>",$echo_text);
             
            $echo_text = str_replace("[quote]","<small><b>Цитат:</b></small><table border=\"0\" width=\"0\" id=\"table1\" style=\"border-style: dotted; border-width: 2px; padding: 0\"><tr><td>",$echo_text);   
            $echo_text = str_replace("[/quote]","</td></tr></table>",$echo_text);   
                   
          $echo_text=preg_replace("/\[code\](.+?)\[\/code\]/s","<small><b>Код:</b></small><table border=\"0\" width=\"0\" id=\"table1\" style=\"border-style: dotted; border-width: 2px; padding: 0\"><tr><td>$1</td></tr></table>",$echo_text);       
                   
            $echo_text = str_replace("[img]","<img border=\"0\" src=\"",$echo_text);   
            $echo_text = str_replace("[/img]","\" alt=\"image\" />",$echo_text);   
                   
       $echo_text = preg_replace('/\[url\](.*)\[\/url\]/Usi','<a class="gensmall" target="_blank" href="$1">$1</a>',$echo_text);
       $echo_text = preg_replace('/\[url=(.*)\](.*)\[\/url\]/Usi','<a class="gensmall" target="_blank" href="$1">$2</a>',$echo_text);
                 
       $echo_text = preg_replace('/\[list\](.*)\[\/list\]/si',"<center>$1</center>",$echo_text);
       $echo_text = preg_replace('/\[list=(.*)\](.*)\[\/list\]/si',"<center>$1</center>",$echo_text);
 
            $echo_text = str_replace("\n", "\n<br />\n", $echo_text);

if($date_time == "long")      // Way to display date and time? long
{
$echo_topic['topic_time'] = strftime("%A %e %B %H:%M",$echo_topic['topic_time']);
}
// Way to display comment link
// Go right to the topic
if ($comment == 'topic')
{
$comment_link = "{$phpbb_root_path}viewtopic.php?t={$echo_topic['topic_id']}";
}

// This link goes to the actual phpbb topic
if ($topic_link == 'phpbb')
{
$topic_link = "{$phpbb_root_path}viewtopic.php?t={$echo_topic['topic_id']}";
}

##################################
## Edit for look and feel of topic
##################################
// Display many topics - for news, shoutbox etc
else if ($show == 'full')
{
if (strlen($echo_text['post_subject'])>$broi_bukvi)
{$totchki='...';}
else
{$totchki='';}
$echo_text['post_subject']=substr($echo_text['post_subject'],0 , $broi_bukvi);
echo "<table class=\"forumline\" border=\"0\" cellpadding=\"2\" cellspacing=\"1\" width=\"100%\"><tbody><tr><td class=\"rowpic\" align=\"left\" valign=\"top\" style=\"background-color: #F0F0F0\"><img src=\"index.php_files/news.gif\" alt=\"news\" /> <font size='1'><b><a class='gensmall' href=\"{$comment_link}\" target=\"_blank\">{$echo_text['post_subject']}$totchki</a></b></font></td></tr></tbody></table><table class=\"forumline\" border=\"0\" cellpadding=\"2\" cellspacing=\"1\" width=\"100%\"><tbody><tr><td class=\"rowpic\" align=\"justify\" valign=\"top\" style=\"background-color: #F3F3F3\">{$echo_text['post_text']}</td></tr></tbody></table><table class=\"forumline\" border=\"0\" cellpadding=\"2\" cellspacing=\"1\" width=\"100%\"><tbody><tr><td class=\"rowpic\" align=\"left\" valign=\"top\" style=\"background-color: #F3F3F3\">Написано на: {$echo_topic['topic_time']} | Коментари: <a class='gensmall' href=\"{$comment_link}\" target=\"_blank\">{$echo_topic['topic_replies']}</a> | Автор: <a class='gensmall' href=\"".$phpbb_root_path."profile.php?mode=viewprofile&u={$echo_user['user_id']}\" target=\"_blank\">{$echo_user['username']}</a></td></tr></tbody></table>";
echo "<br />";
}
}
}
}
}
for($i=1 ; $i<=$total ; $i++)
{
if(($page)==$i)
{
$strani .= "[".$i."] ";
}
else
{
$strani .= "<a href=\"?page=".$i."\">".$i."</a> ";
}
}
echo $strani;
?>
 
ОлЕлЕ :shock: Работи ... за 10 мин и го направи, предавам се направо :shock:

а как ще станеда показва на коя страница съм :roll:
 
porostorm каза:
ОлЕлЕ :shock: Работи ... за 10 мин и го направи, предавам се направо :shock:

а как ще станеда показва на коя страница съм :roll:

Сега не показва ли? даи линк да видя.

и замести
Код:
for($i=1 ; $i<=$total ; $i++)
{
if(($page)==$i)
{
$strani .= "[".$i."] ";
}
else
{
$strani .= "<a href="?page=".$i."">".$i."</a> ";
}
}
с
Код:
for($i=1 ; $i<=$total ; $i++)
{
if(($page)==$i)
{
echo "[".$i."] ";
}
else
{
echo "<a href="?page=".$i."">".$i."</a> ";
}
}
и трябва да ти показва.
 
пробвай го така.

Код:
<?php
for($i=1 ; $i<=$total ; $i++)
{
if(($page)==$i)
{
echo "<b>(".$i.")</b> ";
}
else
{
echo "<a href=\"?page=".$i."\">".$i."</a> ";
}
}

Че си мисля, че може да е заради скобите [ ]
 
Замести това
Код:
for($i=1 ; $i<=$total ; $i++)
{
if(($page)==$i)
{
echo "[".$i."] ";
}
else
{
echo "<a href=\"?page=".$i."\">".$i."</a> ";
}
}
с това
Код:
for($i=1 ; $i<=$total ; $i++)
{
if($page == $i)
{
echo "<b>$i</b>";
}
else
{
echo "<a href=\"?page=".$i."\">".$i."</a> ";
}
}
 
Иии пак не :roll:

Показва само пъртава страница (1) и то, когато URL-то ми е това: /index.php а когато стане /index.php?page=2 2-ра страница НЕ става (2)
 
porostorm каза:
Иии пак не :roll:

Показва само пъртава страница (1) и то, когато URL-то ми е това: /index.php а когато стане /index.php?page=2 2-ра страница НЕ става (2)

е станало е.. като гледам

П.П. не е

П.П.2
Код:
for($i=1 ; $i<=$total ; $i++)
{
if(($page)==$i)
{
echo "<b>$i</b> ";
}
else
{
echo "<a href="?page=".$i."">".$i."</a> ";
}
}
 
тц :( баси работата, ако може обясни къде точно промени кода за да се страницира, че имам още един подобен да го мъча сам
 
Предавам се, не мога да го измисля сега :( а и явно съня надделява над мен

П.П.

махнах
Код:
$limit = '10';
добавих
Код:
$page=$_GET['page'];

if(!$_GET['page'])
{
$page="1";
}

$pp = "10"; //колко на страница

$limit = ($pp*$page)-$pp;

добавих
Код:
$grab = $db->sql_query("SELECT * FROM `{$table_prefix}topics` WHERE `forum_id` = '{$forum}'");
$max=mysql_numrows($grab);
$total=ceil($max/$pp);

добавих
Код:
for($i=1 ; $i<=$total ; $i++)
{
if(($page)==$i)
{
echo "[".$i."] ";
}
else
{
echo "<a href=\"?page=".$i."\">".$i."</a> ";
}
}

преправих
Код:
$grab_topics = $db->sql_query("SELECT * FROM `{$table_prefix}topics` WHERE `forum_id` = '{$forum}' ORDER BY `topic_id` DESC LIMIT $limit,$pp");
 
Отново Ви хвърлям в мислене, като питам следното. С този код(това е урока за четене на цели постове) ми се получава някакъв БъГ. Когато във форума, от който се четат постовете някой напише тема, тя се показва в сайта, обаче ако някой отговори и автора отговори веднага след него(т.е третият пост е отново на автора) в сайта се прочита третото мнение. Много неприятно и немога да го оправя. Някакви идеи :( :( Сега забелязвам, че това си го прави когато си иска. Т.е не на всяка тема :cry:

ето тук можете да видите последните 2 "новини": http://roverclub-bg.com/index.php

едит: Сега вече го хванах какво прави, този номер го прави само на преместените теми от други форуми в този от който чете скрипта :cry:
 
А в момента виждам, че при оригиналния скрипт не го прави този номер :cry: проблема идва някъде от моите разкрасявания :( ПОМОЩ

п.п.: Оказва се, че и оригиналния код го прави този бъг :cry: :(
 
След всичко казано досега излиза, че форумът е виновен за този бъг защото локално не ми ги прави тези проблеми :cry: Интересното е, че има сигурно към 25 теми, които ги извежда както си трябва и сега тези последните нещо ... дали може да е от добавянето на някой мод :roll:
 
Уви колко просто решение на иначе така трудния въпрос за мен!!

Код:
$grab_posts = $db->sql_query("SELECT * FROM `{$table_prefix}posts` WHERE `forum_id` = '{$forum}' AND `topic_id` = '{$echo_topic['topic_id']}' LIMIT 1");
тук поставих ORDER BY `post_id` преди LIMIT 1
Код:
$grab_posts = $db->sql_query("SELECT * FROM `{$table_prefix}posts` WHERE `forum_id` = '{$forum}' AND `topic_id` = '{$echo_topic['topic_id']}' ORDER BY `post_id` LIMIT 1");
и проблемът вече не е проблем :lol: :o

Сега ако може да се върнем на въпроса за страницирането .. как ще стане да показва на коя страница съм :roll:

Благодаря!
 

Back
Горе