![]() |
![]() |
![]()
Post
#1
|
|
Grupa: Zarejestrowani Postów: 23 Pomógł: 3 Dołączył: 8.07.2008 Ostrzeżenie: (0%) ![]() ![]() |
Witam,
chcialem zaciagnac jezyka... wlasnie robie swoja pierwsza strone na smartach lol, nawet juz sa znaczace postepy :D ale jednak przychodzi taki moment gdzie sie staje w miejscu :S chce wyswietlic wyniki zapytania i jak to wyniki, kiedy jest ich duzo przydaje sie sie stornicowanie, nie ukrywam ze korzystam juz ze sciagnietego pluginu :P drinks.html Kod {include file="naglowek.html"} <table> <tr> <td><b>Name:</b></td> <td><b>Category:</b></td> <td><b>Details:</b></td> </tr> <tr></tr> Items {$paginate.first}-{$paginate.last} out of {$paginate.total} displayed. {section name=sekcja loop=$qwyniki} <tr> <td>{$qwyniki[sekcja][1]}</td> <td>{$qwyniki[sekcja][4]}</td> <td><a href=?m=info&id={$qwyniki[sekcja][0]}>more..</td> </tr> {/section} {paginate_prev} {paginate_middle} {paginate_next} </table> {include file="stopka.html"} drinks.php Kod <? session_start(); $smarty =& new Smarty; // required connect SmartyPaginate::connect(); // set items per page SmartyPaginate::setLimit(15); // assign your db results to the template $q=$db->Getall("SELECT * FROM drinks WHERE Category='Misc';"); $smarty->assign("qwyniki",$q); //$smarty->assign("qwyniki", get_db_results()); // assign {$paginate} var SmartyPaginate::assign($smarty); // display results $smarty->display('drinks.html');; function get_db_results() { // normally you would have an SQL query here, // for this example we fabricate a 100 item array // (emulating a table with 100 records) // and slice out our pagination range // (emulating a LIMIT X,Y MySQL clause) $_data = range(1,100); SmartyPaginate::setTotal(count($_data)); return array_slice($_data, SmartyPaginate::getCurrentIndex(), SmartyPaginate::getLimit()); } //print_r($q); ?> zrodlo pluginu: hxxp://www.phpinsider.com/php/code/SmartyPaginate/ wynik: hxxp://cofena.com Czy moze mi ktos powiedziec co zle robie :S bo chyba nie rozumiem dzialania tego pluginu... Dziekuje za wszelkie pomocne instrukcje :) ================================================ ================================================ troche pozmienialem i jest tak: .tpl Kod {include file="naglowek.html"} <table> <tr> <td><b>Name:</b></td> <td><b>Category:</b></td> <td><b>Details:</b></td> </tr> <tr></tr> Items {$paginate.first}-{$paginate.last} out of {$paginate.total} displayed. <br /> {section name=res loop=$results} <tr> <td>{$results[$_data]}</td> </tr> {/section} {* display pagination info *} {paginate_prev} {paginate_middle} {paginate_next} </table> {include file="stopka.html"} .php Kod <? session_start(); require('lib/SmartyPaginate.class.php'); $smarty =& new Smarty; // required connect SmartyPaginate::connect(); // set items per page SmartyPaginate::setLimit(100); // assign your db results to the template $smarty->assign('results', get_db_results()); // assign {$paginate} var SmartyPaginate::assign($smarty); // display results function get_db_results() { $link = mysql_connect('', '', ''); mysql_select_db(''); $query = sprintf("SELECT SQL_CALC_FOUND_ROWS * FROM drinks LIMIT %d,%d", SmartyPaginate::getCurrentIndex(), SmartyPaginate::getLimit()); $result = mysql_query($query); while ($row = mysql_fetch_array($result, MYSQL_ASSOC)) { // collect each record into $_data $data[] = $row; } // now we get the total number of records from the table $query = "SELECT FOUND_ROWS() as total"; $result = mysql_query($query); $row = mysql_fetch_array($result, MYSQL_ASSOC); SmartyPaginate::setTotal($row['total']); mysql_free_result($result); mysql_close($link); return $data; } $smarty->display('drink.html'); //print_r($row); ?> sa juz linki, dzialaja nie do konca, bo jak sie odswierzy strone to sa inne wyniki :S i wyswietla mi juz tylko same linki :S pomozcie no :) Ten post edytował zukowskp 14.07.2008, 15:47:51 |
|
|
![]() ![]() |
![]() |
Aktualny czas: 21.08.2025 - 06:06 |