Witam Próbuje zrozumieć kod skryptu stronicowania. Skrypt wyświeta dobrze. Tyle tylko nie wiem jak przekazać zmienne przy kolejnych stronach wyniku. teraz skrypt przekazuje tylko id_page, chciałbym przekazać inne zmienne np $zm / gdzie zm jest definowane w php/ Przedstawiam fragment kodu który chce zmienić,
function render_links($page_id, $name) { $link = '_class.'<a href="?page_id='. $page_id.'&ak='' "'.$name.' '; return $link; } Dodałem zmienną $zm chce by na stronie jak wybiorę drugą strone w adresie pojawiła się wartośc : id_page=2&ak3 ( 123 to wartośc zmiennej $zm)
a poniżej cały kod / dość długi/ <? class pager { /* przewijanie */ var $_home = '|<'; var $_prev = '<'; var $_next = '>'; var $_end = '>|'; /*classa linkow*/ var $_class = ''; /* wynikow na strone*/
var $_recordonpage ='5';
/* inne :] */ var $page_id = '1'; var $row_number; var $ak; var $page_number; /* linki */ var $home_link; var $prev_link; var $links; var $next_link; var $end_link;
/*konstruktor*/ function pager($row_number, $page_id,$on_page='') { if($on_page!=='') $this-setRecordOnPage($on_page); if(($row_number % $this-_recordonpage)!==0) { $this-page_number = ($row_number / $this-_recordonpage) - (($row_number % $this-_recordonpage) / $this-_recordonpage) + 1; } else { $this-page_number = $row_number / $this-_recordonpage; } $this-row_number = $row_number; if($page_id 0) $this-page_id = $page_id; } /*ustalanie wygladu przewijania*/ function setNav($home, $prev, $next, $end) { if($home!=='') $this-_home=$home; if($prev!=='') $this-_prev=$prev; if($next!=='') $this-_next=$next; if($end!=='') $this-_end=$end; } /*clasa dla linkow*/ function setClass($class) { if($class!=='') $this-_class=$class; } /*ilosc wynikow na strone*/ function setRecordOnPage($on_page) { if($on_page!=='') $this-_recordonpage = $on_page; } /*ustalanie id stron*/ function nav() { $this-home_id = 1; $this-next_id = $this-page_id+1; $this-prev_id = $this-page_id-1; $this-end_id = $this-page_number; } /*tworzenie klas dla linkow*/ function render_class() { if($this-_class!=='') { $this-_class = ' class="'.$this-_class.'"'; } else{ $this-_class='';} } /*wyglad linkow :]*/
function render_links($page_id, $name) { $link = '_class.'<a href="?page_id='. $page_id.'"'.$name.' '; return $link; } /*home*/ function home() { if($this-page_id 1) { $this-home_link = $this-render_links($this-home_id, $this-_home); } } /*prev*/ function prev() { if($this-prev_id 0) { $this-prev_link = $this-render_links($this-prev_id, $this-_prev); } } /*generowanie linkow*/ function links() { /* gdy id jest rowne 1 */ if($this-page_id == '1') { $page_id = 1; while($page_id <= 3) { if($page_id==$this-page_id) { $this-links .= '_class.''. $page_id.' '; } elseif($page_id end_id) { $this-links .= $this-render_links($page_id, $page_id); } $page_id++; } if($page_id end_id) $this-links .= ' '; return true; } /* gdy id jest rowne ostatniej stronie */ if($this-page_id == $this-end_id) {
$page_id = $this-end_id - 2; if($page_id 1) $this-links .= ' '; $page_id_end = $this-end_id; while($page_id <= $page_id_end) { if($page_id==$this-page_id) { $this-links .= '_class.''. $page_id.' '; } elseif($page_id 0){ $this-links .= $this-render_links($page_id, $page_id); } $page_id++; } return true; } /*w innym wypadku :] */ else { if($this-page_id = 4) $this-links .= ' '; $page_id = $this-page_id - 2; $page_id_end = $this-page_id + 2; while($page_id <= $page_id_end) { if($page_id==$this-page_id) { $this-links .= '_class.''. $page_id.' '; } elseif($page_id 0 && $page_id page_number) { $this-links .= $this-render_links($page_id, $page_id); } $page_id++; } if($this-page_id page_number - 3)) $this- links .= ' '; return true; } }
/*next*/ function next() { if($this-next_id page_number) { $this-next_link = $this-render_links($this-next_id, $this-_next); } } /*end*/ function end() { if($this-page_id end_id) { $this-end_link = $this-render_links($this-end_id, $this- _end); } } /*tworzenie pagera*/ function render() { $this-render_class(); $this-nav(); $this-home(); echo $this-home_link; $this-prev(); echo $this-prev_link; $this-links(); echo $this-links; $this-next(); echo $this-next_link; $this-end(); echo $this-end_link; } /*limit*/ function limit() { $limit_min = ($this-_recordonpage * ($this-page_id - 1)); return $limit_min; } /*wyswietlanie ilosci wynikow na strone*/ function onPage() { return $this-_recordonpage; } } ?
Proszę was o pomoc i wskazówki
gmail.com pisze:
Człowieku, zastanów się co robisz. Większośc grupowiczów PRACUJE i nie ma czasu czytać całego Twojego skryptu. Naucz się jasno definiować problem słowami zamiast wklejać kod.
Przygotuj sobie linki poprzedni/następny w PHP:
$poprzedni 'plik.php?strona='.($strona-1).'&zm='.$zm.'&inna_zmienna='.$costam;
$nastepny 'plik.php?strona='.($strona+1).'&zm='.$zm.'&inna_zmienna='.$costam;
a potem je wyświetl i gotowe. Przykład: ">Wstecz<a href="<?= $nastepny ?>">Do przodu
Darek
Skronicowanie jak przekazać zmienne zwa
pyt
Q