Hallo,
auf das ich eine Frage stelle, die schon x-mal beantwortet wurde.
Ich betreibe eine Seite mit Fotos. Nun hab ich mir auch eine Blätterfunktion gebastelt, die soweit auch gut läuft:
Siehe hier:
WORLD-OF-AVIATION.DE - Bjoern Schmitt Aviation Photography - Most recent additions to Gallery
Nun bekomme ich ja 26 Seiten angezeigt. Wie formuliere ich meinen php so um, das ich nur noch 10 Seiten und ein next/prev, und first/last button erhalten?
Also so:
<< < 1 2 3 4 5 6 7 8 9 10 > >>
Der Blättercode:
Der komplette Code:
Sorry wenn ich nerve, ich hab bisher stundenlang im netz gegoogelt und nichts gefunden, was sich einfach hier reinbasteln lässt, oder mir fehlt der horizont
Danke schonmal!
auf das ich eine Frage stelle, die schon x-mal beantwortet wurde.
Ich betreibe eine Seite mit Fotos. Nun hab ich mir auch eine Blätterfunktion gebastelt, die soweit auch gut läuft:
Siehe hier:
WORLD-OF-AVIATION.DE - Bjoern Schmitt Aviation Photography - Most recent additions to Gallery
Nun bekomme ich ja 26 Seiten angezeigt. Wie formuliere ich meinen php so um, das ich nur noch 10 Seiten und ein next/prev, und first/last button erhalten?
Also so:
<< < 1 2 3 4 5 6 7 8 9 10 > >>
Der Blättercode:
PHP-Code:
for ($i=1;$i<=$pages;$i++) {
$newoffset=$limit*($i-1);
print "<a href=\"$PHP_SELF?offset=$newoffset\" class=\"Stil97\" >$i</a> \n";
}
PHP-Code:
<?php
mysql_connect("");
mysql_select_db("");
$limit = 12;
if (!isset($_GET['offset'])) {
$offset = 0;
} else {
$offset = $_GET['offset'];
}
$numresults = mysql_query("select * from bilder order by ID desc");
$numrows = mysql_num_rows($numresults);
$result = mysql_query("select * from bilder order by ID desc Limit $offset, $limit") or die("Couldn't execute query");
$pages=intval($numrows/$limit);
if ($numrows%$limit) {
$pages++;
}
for ($i=1;$i<=$pages;$i++) {
$newoffset=$limit*($i-1);
print "<a href=\"$PHP_SELF?offset=$newoffset\" class=\"Stil97\" >$i</a> \n";
}
$count = 0;
while ($row = mysql_fetch_array($result)) {
$title = $row["dateiname"];
$img = $row["vorschau"];
$description = "Photo-ID: ". $row["id"] ."<br /><br /> Airline:
" . $row["name"] . "<br /> Aircraft:
" . $row["type2"] . "<br /> Registration:
" . $row["reg"] . "<br /><br /> Date:
" . $row["datum"] . "<br /><br /> Location:
" . $row["ort"] . "<br /><br />Views:
" . $row["views"] . "<br /><br />Remarks:
" . htmlspecialchars($row["beschreibung"]) . "<br />"
;
$id = $row["id"];
echo "<table width=\"570px\" cellspacing=\"0\" cellpadding=\"0\" style=\"margin-bottom: 10px; border: 1px solid #000000;\">";
echo "<tr style=\"border-bottom: 1px solid #000000;\">";
echo "<td height=\"20\" bgcolor=\"#78561d\" class=\"Stil99\" width=\"170px\" style=\"border-bottom: 1px solid #000000;\">
<div align=\"center\"><span class=\"Stil99\">Photo ID: ". $row["id"] ." </span></div></td>";
echo "<td colspan=\"2\" bgcolor=\"#78561d\" class=\"Stil99\" style=\"border-bottom: 1px solid #000000;\"> </td>";
echo "</tr><tr>";
echo "<td rowspan=\"2\" class=\"Stil99\" width=\"200px\" bgcolor=\"#666666\" style=\"border-right: 1px solid #000000;\"><br /><div align=\"center\">
<a href=\"getpic.php?id=". $row["id"] ."\"rel=\"lightbox[gallery]\" title=\"$description\">
<img src=\"foto/$img\" style=\"border-color:#111111; border-width:2px; border-style:solid; padding:4px\" alt=\"\" /></a></div><br /></td>";
echo "<td height=\"50%\" width=\"200px\"valign=\"top\" class=\"Stil99\" bgcolor=\"#666666\" style=\"padding-left: 10px;\">
Aircraft:<br /><img src=\"gfx/line.gif\"alt=\"\" /><img src=\"gfx/line.gif\" alt=\"\" /><br /><span class=\"Stil2\">
" . $row["name"] . "<br />
" . $row["type2"] . "</span></td>";
echo "<td height=\"50%\" width=\"170px\"valign=\"top\" class=\"Stil99\" bgcolor=\"#666666\">
Location: <br /><img src=\"gfx/line.gif\" alt=\"\" /><img src=\"gfx/line.gif\" alt=\"\" /><br /><span class=\"Stil2\">
" . $row["ort"] . "</span></td>";
echo "</tr><tr>";
echo "<td height=\"50%\" width=\"200px\" valign=\"top\" class=\"Stil99\" bgcolor=\"#666666\" style=\"padding-left: 10px;\">
Registration/Date:<br /><img src=\"gfx/line.gif\" alt=\"\" /><img src=\"gfx/line.gif\" alt=\"\" /><br /><span class=\"Stil2\">
" . $row["reg"] . "<br />" . $row["datum"] . "</span></td>";
echo "<td height=\"50%\" width=\"200px\" valign=\"top\" class=\"Stil99\" bgcolor=\"#666666\">
Views:<br /><img src=\"gfx/line.gif\" alt=\"\" /><img src=\"gfx/line.gif\" alt=\"\" /><br /><span class=\"Stil2\">
" . $row["views"] . "</span>
<form method=\"post\" action=\"https://www.paypal.com/cgi-bin/webscr\" target=\"paypal\">
<div align=\"right\"><input type=\"hidden\" name=\"cmd\" value=\"_cart\" />
<input type=\"hidden\" name=\"add\" value=\"1\" />
<input type=\"hidden\" name=\"business\" value=\"bjoernschmitt@arcor.de\" />
<input type=\"hidden\" name=\"item_name\" value=\"8x12Inch Print (Matt or Gloss) - 20x30cm Abzug (Matt oder Glaenzend)\" />
<input type=\"hidden\" name=\"item_number\" value=\"Photo ID: ". $row["id"] ." - " . $row["name"] . " - " . $row["type2"] . " - " . $row["reg"] . "\" />
<input type=\"hidden\" name=\"amount\" value=\"7\" />
<input type=\"hidden\" name=\"currency_code\" value=\"EUR\" />
<input type=\"hidden\" name=\"return\" value=\"http://www.world-of-aviation.de\" />
<input type=\"hidden\" name=\"undefined_quantity\" value=\"1\" />
<input type=\"image\" onmouseover=\"this.src='gfx/buynow2.gif'\" onmouseout=\"this.src='gfx/buynow.gif'\" src=\"gfx/buynow.gif\" style=\"border-width=0px\" name=\"submit\" alt=\"Add to Cart\" /></td>
</div></form></td>";
echo "</tr><tr>";
echo "<td valign=\"top\" colspan=\"3\" class=\"Stil99\" bgcolor=\"#666666\" style=\"border-top: 1px solid #000000;\">
Remarks:<span class=\"Stil98\">
". $row["beschreibung"] ."</span><br></td>";
echo "</tr>";
echo "</table>";
}
$count++;
if ($offset > 0) {
$offset_prev = $offset - $limit;
echo " <a href=\"". $_SERVER['PHP_SELF'] ."?offset=$offset_prev\"><img src=\"gfx/previous.gif\" border=\"0\" alt=\"previous photos\" /></a>"; }
if ($offset < ($numrows - $limit)) {
$offset_next = $offset + $limit;
echo " <a href=\"". $_SERVER['PHP_SELF'] ."?offset=$offset_next\"><img src=\"gfx/next.gif\" border=\"0\" alt=\"next photos\" /></a>"; }
?>
Danke schonmal!
Kommentar