|
Smarty
WARNING: All discussion is moving to https://reddit.com/r/smarty, please go there! This forum will be closing soon. |
|
View previous topic :: View next topic |
Author |
Message |
Eistee Smarty Rookie
Joined: 18 Jun 2004 Posts: 10
|
Posted: Tue Jun 29, 2004 12:10 pm Post subject: Blättern über mehrere Seiten |
|
|
Ist es mit Smarty auch möglich, eine Pger-Funktion zu realisieren?
Ich habe berreits ein wenig hier im Forum gesucht, aber leider noch keine Diskussion auf Deutsch gefunden.
Z.Z. bin ich dabei mein GB-Script auf Smarty umzustellen.
Die entsprechende Funktion zum Blättern, sieht so aus, Funktioniert mit der Smarty-Variante aber nicht mehr.
Wie kann ich die Funktion auf Smarty umstricken?
[php:1:82202e04f8]
<?php
$show_entries = 10; // Wieviele Einträge sollen pro Seite angezeigt werden?
if(!isset($start)) $start = 0;
$sqlab = "SELECT * FROM guestbook";
$res = mysql_query($sqlab);
$num = mysql_num_rows($res);
$sqlab = "SELECT * FROM guestbook ORDER BY id DESC LIMIT $start, $show_entries";
$res = mysql_query($sqlab);
$num_pages = ceil($num/$show_entries);
$curr_page = $start/$show_entries;
...
// Folgende Paging-Funktion soll eingebaut werden:
if($curr_page != 0)
{
echo "[<a href=\"?open=gbook&start=".($start-$show_entries)."\"><</a>] ";
}
for($a=0; $a<$num_pages; $a++)
{
if($a != $curr_page)
{
echo "[<a href=\"?open=gbook&start=".($a*$show_entries)."\">".($a+1)."</a>] ";
}
else
{
echo "(".($a+1).") ";
}
}
if(($start+$show_entries)<$num)
{
echo "[<a href=\"?open=gbook&start=".($start+$show_entries)."\">></a>]";
}
}
?>
[/php:1:82202e04f8]
Ich hoffe, ihr versteht was ich meine und könnt mir helfen.
Danke. |
|
Back to top |
|
kills Smarty Elite
Joined: 28 May 2004 Posts: 493
|
|
Back to top |
|
Eistee Smarty Rookie
Joined: 18 Jun 2004 Posts: 10
|
Posted: Tue Jun 29, 2004 12:42 pm Post subject: |
|
|
Ich hab grade auch noch was Interessantes gefunden.
http://www.phpinsider.com/smarty-forum/viewtopic.php?t=494&highlight=paging
Da stellt sich mir nur noch die frage, wie muss meine MySQL-Abfrage in der PHP-datei ausschauen und wie muss ich die Funktion richtig aufrufen?
Wäre super, wenn mir das noch jemand erklären könnte.
hab leider noch nicht so den Durchblick bei smarty... |
|
Back to top |
|
Eistee Smarty Rookie
Joined: 18 Jun 2004 Posts: 10
|
|
Back to top |
|
|
|
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum
|
Powered by phpBB © 2001, 2005 phpBB Group
|