br1 0 Denunciar post Postado Março 4, 2005 Olá pessoal peguei um codigo da internet q nao usa mysql, estou com um probleminha nao consigo limitar o numero de registros a serem exibidos alguem poderia me ajudar, segue o codigo para dar uma analizada.<?PHP$user_query = cute_query_string($QUERY_STRING, array("start_from","total_reg", "archive", "subaction", "id","cnshow","ucat"));$user_post_query = cute_query_string($QUERY_STRING, array("start_from", "total_reg", "archive", "subaction", "id", "cnshow", "ucat"), "post");//####################################################################################################################//####################################################################################################################// Noticias e cabeçahos//####################################################################################################################if($allow_active_and_headline){$all_news = file("$news_file");if($reverse == TRUE){ $all_news = array_reverse($all_news); }if($cnshow != $loc_show){$my_start_from = "";}$count_all = 0;if($category and $category != ""){foreach($all_news as $news_line){$news_arr = explode("|", $news_line);if($my_cats and $my_cats[$news_arr[6]] == TRUE){ $count_all ++; }else{ continue; }}}else{ $count_all = count($all_news); }$i = 0;$showed = 0;$repeat = TRUE;$url_archive = $archive;while($repeat != FALSE){foreach($all_news as $news_line){$news_arr = explode("|", $news_line);if($category and $my_cats[$news_arr[6]] != TRUE){ continue; }if($start_from != "" and $cnshow == $loc_show){if($i < $start_from){ $i++; continue; }elseif($showed == $number){ break; }}if($my_names[$news_arr[1]]){ $my_author = $my_names[$news_arr[1]]; }else{ $my_author = $news_arr[1]; }$output = $my_template;$output = str_replace("{title}", $news_arr[2], $output);$output = str_replace("{date}", date($config_timestamp_active, $news_arr[0]), $output);$output = str_replace("{author}", $my_author, $output);if($news_arr[5] != ""){$output = str_replace("{avatar}", "<img src=\"$news_arr[5]\" border=0>", $output); }else{ $output = str_replace("{avatar}", "", $output); }$output = str_replace("{avatar-url}", "$news_arr[5]", $output);$output = str_replace("[link]","<a href=$PHP_SELF?subaction=showfull&id=$news_arr[0]&archive=$archive&cnshow=$loc_show&start_from=$my_start_from&ucat=$news_arr[6]&$user_query>", $output);$output = str_replace("[/link]","</a>", $output);$output = str_replace("{comments-num}", countComments($news_arr[0], $archive), $output);$output = str_replace("{short-story}", $news_arr[3], $output);$output = str_replace("{full-story}", $news_arr[4], $output);$output = str_replace("{category}", $cat[$news_arr[6]], $output);$output = str_replace("{category-id}", $news_arr[6], $output);if($cat_icon[$news_arr[6]] != ""){ $output = str_replace("{category-icon}", "<img border=0 src=\"".$cat_icon[$news_arr[6]]."\">", $output); }else{ $output = str_replace("{category-icon}", "", $output); }$output = str_replace("{news-id}", $news_arr[0], $output);$output = str_replace("{archive-id}", $archive, $output);$output = str_replace("{php-self}", $PHP_SELF, $output);$output = str_replace("{cute-http-path}", $config_http_script_dir, $output);$output = replace_news("show", $output);if($news_arr[4] != "" or $action == "showheadlines"){//if full storyif($config_full_popup == "yes"){$output = preg_replace("/\\[full-link\\]/","<a href=\"#\" onclick=\"window.open('$config_http_script_dir/show_news.php?subaction=showfull&id=$news_arr[0]&archive=$archive&cnshow=news&ucat=$news_arr[6]>&start_from=$my_start_from', '_News', '$config_full_popup_string');return false;\">", $output);}else{$output = str_replace("[full-link]","<a href=\"$PHP_SELF?subaction=showfull&id=$news_arr[0]&archive=$archive&cnshow=$loc_show&start_from=$my_start_from&ucat=$news_arr[6]&$user_query\">", $output);}$output = str_replace("[/full-link]","</a>", $output);}else{$output = preg_replace("'\\[full-link\\].*?\\[/full-link\\]'si","<!-- no full story-->", $output);}if($config_comments_popup == "yes"){$output = str_replace("[com-link]","<a href=\"#\" onclick=\"window.open('$config_http_script_dir/show_news.php?subaction=showcomments&id=$news_arr[0]&archive=$archive&cnshow=news&start_from=$my_start_from&ucat=$news_arr[6]', '_News', '$config_comments_popup_string');return false;\">", $output);}else{$output = str_replace("[com-link]","<a href=\"$PHP_SELF?subaction=showcomments&id=$news_arr[0]&archive=$archive&cnshow=$loc_show&start_from=$my_start_from&ucat=$news_arr[6]&$user_query\">", $output);}$output = str_replace("[/com-link]","</a>", $output);echo $output;$showed++;$i++;if($number != 0 and $number == $i){ break; }}$used_archives[$archive] = TRUE;// Archives Looopif($i < $number and $only_active != TRUE){if(!$handle = opendir("$cutepath/archives")){ die("<center>Can not open directory $cutepath/archives "); }while (false !== ($file = readdir($handle))){if($file != "." and $file != ".." and eregi("news.arch", $file)){$file_arr = explode(".",$file);$archives_arr[$file_arr[0]] = $file_arr[0];}}closedir($handle);$archives_arr[$in_use]="";$in_use = max($archives_arr);if($in_use != "" and !$used_archives[$in_use]){$all_news = file("$cutepath/archives/$in_use.news.arch");$archive = $in_use;$used_archives[$in_use] = TRUE;}else{ $repeat = FALSE; }}else{ $repeat = FALSE; }}// << Previouse & Next >>$prev_next_msg = $template_prev_next;if($start_from != "" and $start_from > 0){$prev = $start_from - $number;$prev_next_msg = preg_replace("'\[prev-link\](.*?)\[/prev-link\]'si", "<a href=$PHP_SELF?start_from=$prev&archive=$url_archive&subaction=$subaction&cnshow=$loc_show&id=$id&$user_query>\\1</a>", $prev_next_msg);}else{ $prev_next_msg = preg_replace("'\[prev-link\](.*?)\[/prev-link\]'si", "\\1", $prev_next_msg); $no_prev = TRUE; }if($number < $count_all and $i < $count_all){$prev_next_msg = preg_replace("'\[next-link\](.*?)\[/next-link\]'si", "<a href=$PHP_SELF?start_from=$i&archive=$url_archive&subaction=$subaction&cnshow=$loc_show&id=$id&$user_query>\\1</a>", $prev_next_msg);}else{ $prev_next_msg = preg_replace("'\[next-link\](.*?)\[/next-link\]'si", "\\1", $prev_next_msg); $no_next = TRUE;}if (( !$no_prev or !$no_next)and ($cnshow == $loc_show or $cnshow == "" )and (($loc_show == "headlines" and $hide_prev_next_for_headlines != TRUE) or $loc_show != "headlines")and $hide_prev_next != TRUE){ echo $prev_next_msg; }}?> Compartilhar este post Link para o post Compartilhar em outros sites
guma 0 Denunciar post Postado Março 4, 2005 Cara em primeiro lugar nao entendi nada deste codigo (Nao tava afim de ver todo ele ).Tipo se for pesquisa nao banco de dados voce usa LIMIT tipo :SELECT *FROM TABELA LIMIT 5Lista apenas 5 registros no banco de dados se for diferente é so voce colocar dentro de um While ou um For e fazer// linhas é o resultado da minha consulta while ($linhas < 5){echo $linhas ["nome"];}Falou caro qualquer coisa te dou uma mao Compartilhar este post Link para o post Compartilhar em outros sites