dheaven69 Posted April 16, 2007 Share Posted April 16, 2007 <?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 Quote Link to comment https://forums.phpfreaks.com/topic/47283-solved-pagintion-problem-flat-file/ Share on other sites More sharing options...
dheaven69 Posted April 16, 2007 Author Share Posted April 16, 2007 i forgot to say something, if i use $keyword = array_search($keyword, $keyword_file); it shows numbers Quote Link to comment https://forums.phpfreaks.com/topic/47283-solved-pagintion-problem-flat-file/#findComment-230642 Share on other sites More sharing options...
sasa Posted April 16, 2007 Share Posted April 16, 2007 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(); ?> Quote Link to comment https://forums.phpfreaks.com/topic/47283-solved-pagintion-problem-flat-file/#findComment-230650 Share on other sites More sharing options...
dheaven69 Posted April 16, 2007 Author Share Posted April 16, 2007 I LOVE YOU! thank you very much, you just put an end to my misery Quote Link to comment https://forums.phpfreaks.com/topic/47283-solved-pagintion-problem-flat-file/#findComment-230660 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.