Jump to content

[SOLVED] Pagintion Problem | flat file


dheaven69

Recommended Posts

<?php
function pag($items = '4') {
	$keyword = THIS_PAGE_KEYWORD;
	$keyword_file = file(FILE_KEYWORDS);
	$keyword_file = array_map('trim', $keyword_file);
	asort($keyword_file);
	$out .= 'Here STARTS';
	foreach($keyword_file as $keyword) {
	$out .= "\n".'<a href="http://'.THIS_DOMAIN.'/'.str_replace(" ", "-", $keyword).'" title="'.$keyword.'">'.$keyword.'</a><br />';
	$n++;
	if ($n >= $items) {
		break;
	}
}
$out .= 'Here ENDS';
print $out;
}
?>

 

This code gest the urls from a text file.

The problem is that is not detecting the curent keyword and does not advance the menu

 

lets say you have

$keyword_file = array(apple, brain, computer, drain, elemental, fruit, green)

$keyword = computer

 

well it should print

 

computer

drain

elemental

fruit

 

but it doesn't

it always show the first elements

 

 

 

 

SEARCH TAGS: Pagination, Flat File, Text File, No MySQL, No DataBase, No DB

Link to comment
https://forums.phpfreaks.com/topic/47283-solved-pagintion-problem-flat-file/
Share on other sites

try

<?php
function pag($items = '4') {
$n = 0;
$out = '';
$keyword_file = array('apple', 'brain', 'computer', 'drain', 'elemental', 'fruit', 'green');
$keyword = 'computer';
$keyword_file = array_map('trim', $keyword_file);
asort($keyword_file);
$out .= 'Here STARTS';
$test = false;
foreach($keyword_file as $keyword1) {
	if ($keyword == $keyword1) $test = true;
	if ($test) {
		$out .= "\n".'<a href="http://'.THIS_DOMAIN.'/'.str_replace(" ", "-", $keyword1).'" title="'.$keyword1.'">'.$keyword1.'</a><br />';
		$n++;
		if ($n >= $items) break;
	}
}
$out .= "\n".'Here ENDS';
print $out;
}
pag();
?>

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.