Bildergallerie mit Button "next" und "back"

Ich habe folgendes Problem:

Möchte gerne eine Bildergallerie erstellen. Der Code dafür steht und funktioniert. Jetzt möchte ich aber nur 10 bilder darstellen (pro Seite).
Man sollte mit einem einfachen klick ("next") zu den nächsten 10 Bildern gelangen.
Habe bereits gegoogelt aber nichts schlaues gefunden.
Hilfe!!!

hier mien Code:
PHP:
<?php
/**
  * <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<WAS SOLL ANEZEIGT WERDEN?>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
  */
/**
  * ANGEBEN IN WELCHEM VERZEICHNIS GESUCHT WERDEN MUSS
  */
$bilder = opendir("img\phptest");
$verzeichnisinhalt = array();
while (true == ($file = readdir($bilder)))
/**
  * DIE RICHTIGEN DATEIENDUNGEN ABFRAGEN (GIF UND JPG)
  * (MIT STRTLOWER ALLE NAMEN IN KLEINBUCHSTABEN AUSGEBEN)
  * UND IN $FILE ABLEGEN
  */
{
        if ((substr(strtolower($file), -3)=="jpg") or (substr(strtolower($file), -3)=="gif"))      
        {        
            $verzeichnisinhalt[] = $file;
        }    
}
/**
  *  <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<WIE SOLLEN DIE BILDER ANGEZEIGT WERDEN?>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
  */
/**
  * EINE TABELLE ERZEUGEN IN WELCHER DANN DIE BILDER SPÄTER ANGEZEIGT WERDEN KÖNNEN
  */
echo "<div id='Galerie'><table width='600' cellspacing='50'>";
for($i=0;$i<count($verzeichnisinhalt);$i++)
/**
  * DIE BILDER MÜSSEN NUN NOCH EINGEFÜGT WERDEN
  */  
{
    echo "<tr><td>";//TABELLENREIHE UND SPALTE
    echo "<img src='img\phptest\\".$verzeichnisinhalt[$i]."' height=150 width=200 >
	<br><center>".substr($verzeichnisinhalt[$i],0,strlen($verzeichnisinhalt[$i])-4)."</center></img></td>"; 
    $i++;
    if( $i < count($verzeichnisinhalt) )
    {
        echo "<td><img src='img\phptest\\".$verzeichnisinhalt[$i]."' height=150 width=200 >
		<br><center>".substr($verzeichnisinhalt[$i],0,strlen($verzeichnisinhalt[$i])-4)."</center></img></td>"; 
    }
	
    echo "</tr>";
}
echo "</table></div>";
?>

Danke schon mal jetzt....
 
machs mit ner kleinen start hilfe:

deine erste seite hat den link "deineseite.php?start=0"

füge vor deine Tabelle folgenden code ein:

PHP:
//==========================
$start=$HTTP_GET_VARS["start"];
//back
if($start==0){$prev="";}else{$prev_start=$start-10; $prev='<a href="deineseite.php?start='.$prev_start.'">back</a>';}

//next
$next_start=$start+10;
if($next_start>count($verzeichnisinhalt)){$next="";$ende=count($verzeichnisinhalt);}
else{$next='<a href=deineseite.php?start='.$next_start.'">next</a>';$ende=$next_start-1;}

//Deine FOR Schleife für deine Bilder in der Tabelle  muss dann so beginnen:

for($i=$start;$i<$ende;$i++){ 
/* wie gehabt*/ 
}


und unter deine tabelle einfach nur

PHP:
echo $prev.'  '.$next;

mfg DaRaffa
 
Dankeschön...
Funzt...Schreibe den Code gerade um (der Übersicht zuliebe) und hoffe das prinzip verstanden zu haben.

Also hier für alle Interessierten mein neuer "fertiger" Gallerie-code:

<?php
/**
* <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<WIE SOLLEN DIE BILDER ANGEZEIGT WERDEN?>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
*/
/**
* EINE TABELLE ERZEUGEN IN WELCHER DANN DIE BILDER SPÄTER ANGEZEIGT WERDEN KÖNNEN
*/
$anzahlSpalten = 2;
$anzahlBilder = 4;
// int = integer = Ganzzahl
// float = Fliesskommazahl
$anzahlReihen = intval(($anzahlBilder / $anzahlSpalten ));
/**
* <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<WAS SOLL ANEZEIGT WERDEN?>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
*/
/**
* ANGEBEN IN WELCHEM VERZEICHNIS GESUCHT WERDEN MUSS
*/
$bilder = opendir("$galerien");
$verzeichnisinhalt = array();
/**
* DIE RICHTIGEN DATEIENDUNGEN ABFRAGEN (GIF UND JPG)
* (MIT STRTLOWER ALLE NAMEN IN KLEINBUCHSTABEN AUSGEBEN)
* UND IN $VERZEICHNISINHALT ABLEGEN
*/

while (true == ($file = readdir($bilder))){
if ((substr(strtolower($file), -3)=="jpg") or (substr(strtolower($file), -3)=="gif") or (substr(strtolower($file), -3)=="png")){
$verzeichnisinhalt[] = $file;
}
}
print '<table>';
/**
*****************************************************BILDNAVIGATION *******************************************************************
*/
/**
* "10 BILDER ZURÜCK"
*/
$start =$_GET['start'];
$back =$start-$anzahlBilder;

$backLink = "";
$nextLink = "";
if($start==0){
$prev="";
}elseif($start - $anzahlBilder < 0){
$back = 0;
$backLink = '<a href="verzeichnis.php?start='.$back.'">zurück</a>';
}else{
$back = $start-$anzahlBilder;
$backLink = '<a href="verzeichnis.php?start='.$back.'">zurück</a>';
}
/**
* "10 BILDER VOR"
*/
$next = $start+$anzahlBilder;
if($next>count($verzeichnisinhalt)-1){
$next="";
$ende=count($verzeichnisinhalt);
}else{
$next=$start+$anzahlBilder;
$nextLink='<a href="verzeichnis.php?start='.$next.'">weiter</a>';
}
/**
*<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<AUSGABE DER BILDER>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
*/
for ($reihe=0;$reihe < $anzahlReihen;$reihe++){
print '<tr>';
for ($spalte=0;$spalte < $anzahlSpalten;$spalte++){
print '<td style="border-style: groove; border-size:2px; height: 200px; width:200px">';
if (isset($verzeichnisinhalt[$start])){
print '<img src="img/'.$verzeichnisinhalt[$start].'"height="200" width="200">';
}else{
print ' ';
}
print '</td>';
$start++;
}
print '</tr>';
}
print '</table>';


if ($backLink){
print $backLink.'  ';
}
if ($nextLink){
print '  '.$nextLink;
}

?>

Danke nochmals @daRaffa für die nützliche Hilfestellung :]
mfg edj
 
PHP:
   <?php
    $start = (isset($_GET['start'])) ? $_GET['start'] : "1";
?>

würde dir die möglichkeit bieten, dass du einfahc nur gallery.php aufrufst beim ersten mal anstatt gallery.php?start=1

...
 
Zurück
Oben