000
07.03.2002, 20:11
chriss
|
aalso das NoX.Book ist mein erstes sql projekt (an dieser stelle thx an Morpheus, Nebrot und MotS), was php angeht bin mittlerweile recht fit, nur mit sql hab ich noch abundzu probs..
naja lange rede kurzer (un)sinn, ich hab keine ahung wie ich so eine archiv funktion einbauen kann..
<? // Included Files include("inc/connect.inc.php"); include("inc/config.inc.php"); include("inc/parse.inc.php"); // Included Files echo " <html> <head> <title>$title</title> </head> <body> "; $gbook_tabelle = mysql_query("SELECT * FROM gbook ORDER BY id Desc"); WHILE ( $gbook = mysql_fetch_array($gbook_tabelle) ) { $gbook[msg] = parse_html( $gbook[msg] ); $gbook[msg] = str_replace ("\n", "<BR>", $gbook[msg]); echo " <table align="center" width="450" cellspacing="0" cellpadding="0" border="0"> <tr heigth="40"> <td bgcolor="#6F7184"><small><small>Eintrag: [$gbook[id]]</small></small><br> <a href="mailto:$gbook[mail]"<b>$gbook[nick]</b></a> - (<a href="$gbook[hp]">$gbook[hp]</a>)<br> schrieb:<br> </td> </tr> <tr valign="top"> <td bgcolor="#87899A"><br> $gbook[msg] <br></td> </tr> "; if ($gbook[comment] != "") { echo " <tr height="20"> <td bgcolor="#87899A"><br> <i><br> <b>Kommentar des Moderators:</b><br> $gbook[comment]</i></td>"; } echo " </tr> </table>";
}
// Included Files include("inc/footer.inc.php"); ?>
das ist der Quellcode der Ausgabe datei..
thx for support..
--
|
|
Profil || Suche
|
001
07.03.2002, 20:41
Joker
|
ich hab mir den code nicht angeschaut... aber nach titel gib ich dir mal paar tips
zuerst auslesen wieviel datensätze angezeigt werden ( "select count(*) from xxx")
dann kannst du die erhaltene zahl diviediert durch die datensätze, die angezeigt werden sollen also z.b.
$seiten = $anzahl / 25;
dann musst du aufrunden... weil du ja nicht 3.23452345 seiten willst...
also mach $seiten = ceil($seiten); // ich glaub das geht so...
jo... dann weisst du wieviel seiten das es gibt... so kannst du oben beim GB mal schreiben
Seite: 1 2 3 4 5 etc. etc...
zum auslesen solltest du das Limit bei mysql benutzen... ist genial
select xxx from xxx order by xxx limit 0,25 (0 steht für anfangswert. also bei seite 2 sollte der auf 25 sein... / 25 steht für einträge, die ins resultat kommen sollen / ein order by brauchst du schon, damit auch der neuste zuerst kommt)
ich weiss nicht ob das verständlich ist... sonst fragen :D
--
-=[ Aigu.ch ]=-
|
|
Profil || Suche
|
002
07.03.2002, 20:43
TheTinySteini
|
Snippets aus meinem Gästebuch-Code:
$q_entries = mysql_query( "SELECT date, name, city, email, entry FROM gb_entries ORDER BY date DESC LIMIT $start, $limit" );
...
if( $count > $limit ) { echo '<p><img src="../pics/linie_klein.gif" width="640" height="2" alt="" border="0"><br> <table border="0" width="640"> <tr><td align="center">[ '; if( $start > 0 ) { $prev = $start - $limit; if( $prev < 0 ) $prev = 0; echo '<a href="?start='.(int)$prev.'">Neuere</a> '; } if( ($start + $limit) < $count ) { if( $start > 0 ) echo '| '; echo '<a href="?start='.($start + $limit).'">Ältere</a> '; } echo ']</tr></td></table></p>'; }
$start und $limit musste natürlich setzen, $count ist die Gesamtzahl der Einträge (per mysql-query erfragen).
--
TheTinySteini Coder Poke646 "Don't Panic" - Hitchhiker's Guide to the Galaxy
|
|
Profil || Suche
|
003
07.03.2002, 20:59
chriss
|
thx for all, aber de|andy hats mir im chat erklärt :) für die die auch grad sql lernen:
<? // Included Files include("inc/connect.inc.php"); include("inc/config.inc.php"); include("inc/parse.inc.php"); // Included Files echo " <html> <head> <title>$title</title> </head> <body>
";
if( !$startid ) { $startid = 0; } // sicherstellen, das auf der ersten seite der erste eintrag von null gezählt wird. // $gbook_tabelle = mysql_query("SELECT * FROM gbook LIMIT $startid, 10 ORDER BY id Desc"); // neu, limit hinzugefügt, er wird immer 10 gästebucheinträge anzeigen. $gbook_tabelle = mysql_query('SELECT * FROM gbook ORDER BY id Desc LIMIT '.$startid.', 10'); $gbook_tabelle2 = mysql_query('SELECT * FROM gbook'); $maxi = mysql_num_rows($gbook_tabelle); //$startid += 10; damit nach dem klick auf dem link auch die nächsten 10 einträge angezeigt werden $backid = $startid - 10; echo "<center>"; if( ($startid + 10) >= mysql_num_rows($gbook_tabelle2)) { echo "Nächste Seite"; } else { $startid += 10; echo "<!-- Vor!! --><a href="insert.php?startid=$startid">Nächste Seite</a><!-- ENDE Vor!! -->"; } echo " || ";
if( $backid < 0 ) { echo "Vorige Seite"; } else { echo "<!-- back! --><a href="insert.php?startid=$backid">Vorige Seite</a><!-- ENDE Back! -->"; } echo "</center>";
WHILE ( $gbook = mysql_fetch_array($gbook_tabelle) ) { $gbook[msg] = parse_html( $gbook[msg] ); $gbook[msg] = str_replace ("\n", "<BR>", $gbook[msg]);
echo " <table align="center" width="450" cellspacing="0" cellpadding="0" border="0"> <tr heigth="40"> <td bgcolor="#6F7184"><small><small>Eintrag: [$gbook[id]]</small></small><br> <a href="mailto:$gbook[mail]"<b>$gbook[nick]</b></a> - (<a href="$gbook[hp]">$gbook[hp]</a>)<br> schrieb:<br> </td> </tr> <tr valign="top"> <td bgcolor="#87899A"><br> $gbook[msg] <br></td> </tr> "; if ($gbook[comment] != "") { echo " <tr height="20"> <td bgcolor="#87899A"><br> <i><br> <b>Kommentar des Moderators:</b><br> $gbook[comment]</i></td>"; } echo " </tr> </table>";
}
// Included Files include("inc/footer.inc.php"); ?>
--
Dieser Beitrag wurde am 07.03.2002 um 22:11 von NoX bearbeitet.
|
|
Profil || Suche
|