PHP-Code:
<div align=left><font size=3 face=Times New Roman><b>
News Überblick:
</b></font></div><br>
<?php
$step = $diff = 10;
$r = mysql_query("SELECT count(*) FROM news") or die(mysql_error());
$anz = mysql_result($r,0);
if ($offset+1>=$anz-$step) {
$offset = $anz-$step;
$diff = $anz % $diff;
$disabled[next] = TRUE;
}
if (!$offset || $offset<0) {
$offset = 0;
$disabled[prev] = TRUE;
}
$r = mysql_query("SELECT * FROM news ORDER BY id DESC LIMIT $offset,$diff") or die(mysql_error());
while ($daten = mysql_fetch_array($r)) {
echo "<table width=100% bgcolor=#C10000 cellpadding=3 border=0 cellspacing=3>";
echo "<tr><td align=left bgcolor=#000000>";
echo "<font size=3 face=Times New Roman>";
echo "<b>$daten[title]</b>";
echo "</font>";
echo "</td></tr>";
echo "<tr><td align=left bgcolor=#000000>";
echo "<font size=2 face=Times New Roman>";
echo "<b>$daten[content]</b><br><br>";
$ip = $REMOTE_ADDR;
$result = mysql_query("SELECT user FROM login WHERE ip='$ip'");
if (mysql_num_rows($result) == 1) {
echo "<div align=right>";
echo "<b><a href='news_edit.php?action=del_news&id=$daten[id]'>Löschen</a> <a href='news_edit.php?action=edit_news&id=$daten[id]'>Bearbeiten</a></b>";
echo "</div>";
}
echo "</font>";
echo "</td></tr>";
echo "<tr><td align=right bgcolor=#000000>";
echo "<table border=0 cellpadding=0 width=100% cellspacing=0>";
echo "<tr><td align=left>";
echo "<font size=2 face=Times New Roman>";
echo "<b>$daten[date]</b>";
echo "</font>";
echo "</td><td align=right>";
echo "<font size=2 face=Times New Roman>";
$get_email = mysql_query("SELECT email FROM members WHERE name='$daten[name]'") or die(mysql_error());
$email = mysql_fetch_array($get_email);
echo "<b>postet by <a href='mailto:$email[email]'>$daten[name]</a></b>";
echo "</font>";
echo "</table>";
echo "</td></tr>";
echo "</table><br>";
}
echo "<div align=right><font size=2 face=Times New Roman><b>";
if ($disabled[prev]!==TRUE) echo '<a href="'.$PHP_SELF.'?offset='.($offset-$step).'">Vorherige Seite</a>';
for ($i=1;$i<=($anz/$step);$i++) echo '<a href="'.$PHP_SELF.'?offset='.($i*$step).'"> '.$i.'</a>';
if ($disabled[next]!==TRUE) echo '<a href="'.$PHP_SELF.'?offset='.($offset+$step).'">Nächste Seite</a>';
echo "</b></font></div>";
?>
Den Code hab ich hier aus dem Forum.
Was stimmt da nicht?
Kommentar