Jump to content

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();
?>

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.