trier une galerie d'image

diab
Invité n'ayant pas de compte PHPfrance

03 oct. 2005, 00:19

bonjour j'aimerais trier les images d'une galerie photo soit par ordre alphabétique soit le contraire ou encore par ordre de ajout....

c'est un dossier dans lequel je met les image et il me crée automatiquement les miniatures et fait la mise en page de la galerie mais tout les images sont classée par ordre alphabétique....

voici le code:
<?php
$col_simple		= "non"; 	// Si $col_simple == Oui Alors presentation speciale sur une colonne
					// avec gestion des pages, on affiche par page le nbr_colonne * nbre_ligne
					// Si $col_simple != Oui Alors on affiche une mosaique en tenant compte de
					// nbr_colonne et nbr_ligne 

$nbr_colonne		=5;
$nbr_ligne		=3;


$image_de_fond		= "#ffffff";
$thumb			= "thumb/"; // Si Oui, on utilise le repertoire /thumb pour la mosaique
$pourcentage_reduce 	= 60;
$RepGrosseImages 	= "climb/images/";
$faire_miniature 	= "Non"; //En developpement
//Taille de l'extension = 3 // 3 : pour jpg 4 : jpeg
///////////////////////////////////////////////////////////////////////////////////////////

function GetFileList( $dirname="." ) {   
   $files = array(); 
  
   $dir = opendir( $dirname );
   while( $file = readdir( $dir ) ) {
      if (ereg("jpg$",$file) || ereg("JPG$",$file) || 
          ereg("jpeg$",$file) || ereg("JPEG$",$file) ||
          ereg("png$",$file) || ereg("PNG$",$file) ||
	  ereg("gif$",$file) || ereg("GIF$",$file)
	  ) {
          $files[] = $file; 
      }
   }
   sort($files);
   return $files;
}

?>

<HTML>
<HEAD>
  <TITLE></TITLE>
  <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1"><style type="text/css">
<!--
a:link {
	color: #FFFFFF;
	text-decoration: none;
}
a:visited {
	text-decoration: none;
	color: #FFFFFF;
}
a:hover {
	text-decoration: underline;
}
a:active {
	text-decoration: none;
}
body,td,th {
	color: #FFFFFF;
}
body {
	background-color: #000000;
}
-->
</style><body alink="#FFFFFF" background=
  <?php echo "\"$image_de_fond\""; ?>
  >
  
</HEAD>

<SCRIPT Language="JavaScript">  
<!--   
var popWin = null    
var winCount = 0 
var winName = "popWin" 

function openPopWin(winURL, winWidth, winHeight, winFeatures, winLeft, winTop){ 
  var d_winLeft = 0  
  var d_winTop = 0   
  winName = "popWin" + winCount++  
  closePopWin()           
  if (openPopWin.arguments.length >= 4)    
    winFeatures = "," + winFeatures 
  else  
    winFeatures = ""  
  if (openPopWin.arguments.length == 6)   
    winFeatures += getLocation(winWidth, winHeight, winLeft, winTop) 
  else 
    winFeatures += getLocation(winWidth, winHeight, d_winLeft, d_winTop) 
  popWin = window.open(winURL, winName, "width=" + winWidth  
           + ",height=" + winHeight + winFeatures) 
  } 

function closePopWin(){     
  if (navigator.appName != "Microsoft Internet Explorer"  
      || parseInt(navigator.appVersion) >=4)  
    if(popWin != null) if(!popWin.closed) popWin.close()  
  } 

function getLocation(winWidth, winHeight, winLeft, winTop){ 
  return "" 
  } 
//--> 
</SCRIPT> 
<SCRIPT Language="JavaScript1.2"> 
<!-- 
function getLocation(winWidth, winHeight, winLeft, winTop){ 
  var winLocation = "" 
  if (winLeft < 0) 
    winLeft = screen.width - winWidth + winLeft 
  if (winTop < 0) 
    winTop = screen.height - winHeight + winTop 
  if (winTop == "cen") 
    winTop = (screen.height - winHeight)/2 - 20 
  if (winLeft == "cen") 
    winLeft = (screen.width - winWidth)/2 
  if (winLeft>0 & winTop>0) 
    winLocation =  ",screenX=" + winLeft + ",left=" + winLeft     
                + ",screenY=" + winTop + ",top=" + winTop 
  else 
    winLocation = "" 
  return winLocation 
  } 
//--> 
</SCRIPT> 

<p>
<center>

</p>
</center>
<?

if ($col_simple	!= "Oui")
{
echo "<table border=\"0\" align=\"center\" cellspacing=\"0\" cellpadding=\"6\"> \n"; 
}
else
{
echo "<table width=\"600\" border=\"1\" cellspacing=\"0\" cellpadding=\"2\" align=\"center\"> \n";
echo "  <tr bgcolor=\"#999999\">  \n"; 
echo "    <td>  \n";
echo "      <div align=\"center\"><font face=\"Verdana, Arial, Helvetica, sans-serif\" size=\"2\">Apercu</font></div> \n";
echo "    </td> \n";
echo "    <td>  \n";
echo "      <div align=\"center\"><font face=\"Verdana, Arial, Helvetica, sans-serif\" size=\"2\">Nom</font></div> \n";
echo "    </td> \n";
echo "    <td>  \n";
echo "      <div align=\"center\"><font face=\"Verdana, Arial, Helvetica, sans-serif\" size=\"2\">Largeur</font></div> \n";
echo "    </td> \n";
echo "    <td>  \n";
echo "      <div align=\"center\"><font face=\"Verdana, Arial, Helvetica, sans-serif\" size=\"2\">Hauteur</font></div> \n";
echo "    </td> \n";
echo "  </tr> \n";
}

$imagelist = GetFileList($RepGrosseImages);

$nbr_par_page	=$nbr_colonne * $nbr_ligne;
$nbr_tot		=count($imagelist);
$debut		= 1;
$j	   		= 1;
$fin			= $nbr_par_page;


if (!isset($ppage))
{
	$ppage=1;
}

for($i=$debut; $i < $nbr_tot +1 ; $i++) {

	$image		= $imagelist[$i-1];

	if (file_exists("$RepGrosseImages$image"))
	{
	$size 		= getimagesize("$RepGrosseImages$image");
	$width		= $size[0];
	$height		= $size[1];
	$rwidth		= $size[0]+20;
	$rheight	= $size[1]+20;
	$page		= ceil($i/$nbr_par_page);
	$tpage[$i] = $page ;
	}

if ($page == $ppage)
{
   if ($col_simple	!= "Oui")
   {
		if ($j == ( $nbr_colonne ) )
		{
			echo " <td> \n";
			echo " <center> \n";
			echo " <a href='javascript:openPopWin(\"$RepGrosseImages$image\",$rwidth,$rheight,\"\",\"cen\",\"cen\")'> \n";
			if ($thumb == "Oui")
				{
				echo " <img src='thumb/$image' border=0 alt='$image*$width*$height' \n";
				}
			else
				{
				echo " <img src='$RepGrosseImages$image' border=0 alt='$image*$width*$height' \n";
				}
			echo " width='$pourcentage_reduce'><br><font face=\"Arial,Helvetica\"><font size=-2>$image</font></font></a></td> \n";
			echo "</center> \n";
			echo "</tr> \n";
			$j = 1;
		}
		else
		{
			echo " <td> \n";
			echo " <center> \n";
			echo " <a href='javascript:openPopWin(\"$RepGrosseImages$image\",$rwidth,$rheight,\"\",\"cen\",\"cen\")'> \n";
			if ($thumb == "Oui")
				{
				echo " <img src='thumb/$image' border=0 alt='$image*$width*$height' \n";
				}
			else
				{
				echo " <img src='$RepGrosseImages$image' border=0 alt='$image*$width*$height' \n";
				}

			echo " width='$pourcentage_reduce'><br><font face=\"Arial,Helvetica\"><font size=-2>$image</font></font></a></td></center> \n";
			$j = $j + 1;
		}

   }
   else
   {
	echo "<tr> \n";
        echo "<td> \n";
        echo "<div align=\"center\"><a href='javascript:openPopWin(\"$RepGrosseImages$image\",$rwidth,$rheight,\"\",\"cen\",\"cen\")'> \n";

		if ($thumb == "Oui")
			{
			echo " <img src='thumb/$image' border=0 alt='$image*$width*$height' \n";
			}
		else
			{
			echo " <img src='$RepGrosseImages$image' border=0 alt='$image*$width*$height' \n";
			}

        echo "     width='50'></a></div> \n";
        echo "</td> \n";
        echo "<td>  \n";
        echo "<div align=\"center\"><font face=\"Verdana, Arial, Helvetica, sans-serif\" size=\"1\">$image</font></div> \n";
        echo "</td> \n";
        echo "<td>  \n";
        echo "<div align=\"center\"><font face=\"Verdana, Arial, Helvetica, sans-serif\" size=\"1\">$rwidth</font></div> \n";
        echo "</td> \n";
        echo "<td>  \n";
        echo "<div align=\"center\"><font face=\"Verdana, Arial, Helvetica, sans-serif\" size=\"1\">$rheight</font></div> \n";
        echo "</td> \n";
        echo "</tr> \n";
        $j = $j + 1;
   }
} //if
} //for

echo "</table> \n";
echo "<BR> \n";
echo "<CENTER> \n";
$sval = -1;
while (list ($key, $val) = each ($tpage)) {

	if ($sval != $val)
	{
	echo "<b><font face=\"Verdana, Arial, Helvetica, sans-serif\" size=\"1\">[\n";
	echo "<a href=\"index.php?page=climb&ppage=$val\">$val</a>";
	echo "]\n";
	$sval = $val;
	}
}
echo "</CENTER> \n";

?>

Mammouth du PHP | 19672 Messages

03 oct. 2005, 01:43

Je commencerais par te suggérer de faire du code propre en séparant le PHP du HTML, comme ceci:
<?php
$col_simple   = "non";     // Si $col_simple == Oui Alors presentation speciale sur une colonne
                           // avec gestion des pages, on affiche par page le nbr_colonne * nbre_ligne
                           // Si $col_simple != Oui Alors on affiche une mosaique en tenant compte de
                           // nbr_colonne et nbr_ligne

$nbr_colonne  =5;
$nbr_ligne    =3;

$image_de_fond       = "#ffffff";
$thumb               = "thumb/"; // Si Oui, on utilise le repertoire /thumb pour la mosaique
$pourcentage_reduce  = 60;
$RepGrosseImages     = "climb/images/";
$faire_miniature     = "Non"; //En developpement
//Taille de l'extension = 3 // 3 : pour jpg 4 : jpeg
///////////////////////////////////////////////////////////////////////////////////////////

function GetFileList( $dirname="." )
{
    $files = array();

    $dir = opendir( $dirname );
    while( $file = readdir( $dir ) )
    {
        if (ereg("jpg$",$file) || ereg("JPG$",$file) ||
        ereg("jpeg$",$file) || ereg("JPEG$",$file) ||
        ereg("png$",$file) || ereg("PNG$",$file) ||
        ereg("gif$",$file) || ereg("GIF$",$file))
        {
            $files[] = $file;
        }
    }
    sort($files);
    return $files;
}
?>
<HTML>
<HEAD>
  <TITLE></TITLE>
  <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1"><style type="text/css">
<!--
body {
    font-family: Verdana, Arial, Helvetica, sans-serif;
}
a:link {
    color: #FFFFFF;
    text-decoration: none;
}
a:visited {
    text-decoration: none;
    color: #FFFFFF;
}
a:hover {
    text-decoration: underline;
}
a:active {
    text-decoration: none;
}
body,td,th {
    color: #FFFFFF;
}
body {
    background-color: #000000;
}
-->
</style><body alink="#FFFFFF" background="<?php echo $image_de_fond; ?>">
</HEAD>
<SCRIPT Language="JavaScript">  
<!--
var popWin = null
var winCount = 0
var winName = "popWin"

function openPopWin(winURL, winWidth, winHeight, winFeatures, winLeft, winTop)
{
    var d_winLeft = 0
    var d_winTop = 0
    winName = "popWin" + winCount++
    closePopWin()
    if (openPopWin.arguments.length >= 4)
    {
        winFeatures = "," + winFeatures
    }
    else
    {
        winFeatures = ""
    }
    if (openPopWin.arguments.length == 6)
    {
        winFeatures += getLocation(winWidth, winHeight, winLeft, winTop)
    }
    else
    {
        winFeatures += getLocation(winWidth, winHeight, d_winLeft, d_winTop)
    }
    popWin = window.open(winURL, winName, "width=" + winWidth + ",height=" + winHeight + winFeatures)
}

function closePopWin()
{
    if (navigator.appName != "Microsoft Internet Explorer" || parseInt(navigator.appVersion) >=4)
    {
        if(popWin != null)
        {
            if(!popWin.closed)
            {
                popWin.close()
            }
        }
    }
}

function getLocation(winWidth, winHeight, winLeft, winTop)
{
    return ""
}
//-->
</SCRIPT>
<SCRIPT Language="JavaScript1.2">
<!--
function getLocation(winWidth, winHeight, winLeft, winTop)
{
    var winLocation = ""
    if (winLeft < 0)
    {
        winLeft = screen.width - winWidth + winLeft
    }
    if (winTop < 0)
    {
        winTop = screen.height - winHeight + winTop
    }
    if (winTop == "cen")
    {
        winTop = (screen.height - winHeight)/2 - 20
    }
    if (winLeft == "cen")
    {
        winLeft = (screen.width - winWidth)/2
    }
    if (winLeft>0 & winTop>0)
    {
        winLocation =  ",screenX=" + winLeft + ",left=" + winLeft + ",screenY=" + winTop + ",top=" + winTop
    }
    else
    {
        winLocation = ""
    }
    return winLocation
}
//-->
</SCRIPT>
<p>
<center>
</center>
</p>
<?
if ($col_simple != "Oui")
{
?>
<table border="0" align="center" cellspacing="0" cellpadding="6">
<?php
}
else
{
    $param = " width=\"600\" border=\"1\" cellspacing=\"0\" cellpadding=\"2\" align=\"center\"";
?>
<table width="600" border="1" cellspacing="0" cellpadding="2" align="center">
  <tr bgcolor="#999999">
    <td>
      <div align="center"><font size="2">Apercu</font></div>
    </td>
    <td>
      <div align="center"><font size="2">Nom</font></div>
    </td>
    <td>
      <div align="center"><font size="2">Largeur</font></div>
    </td>
    <td>
      <div align="center"><font size="2">Hauteur</font></div>
    </td>
  </tr>
<?php
}
$imagelist = GetFileList($RepGrosseImages);

$nbr_par_page    = $nbr_colonne * $nbr_ligne;
$nbr_tot         = count($imagelist);
$debut           = 1;
$j               = 1;
$fin             = $nbr_par_page;

$ppage = isset($_GET['ppage']) ? $_GET['ppage'] : 1;

for($i=$debut; $i < $nbr_tot +1 ; $i++)
{
    $image = $imagelist[$i-1];

    if (file_exists($RepGrosseImages.$image))
    {
        $size      = getimagesize($RepGrosseImages.$image);
        $width     = $size[0];
        $height    = $size[1];
        $rwidth    = $size[0]+20;
        $rheight   = $size[1]+20;
        $page      = ceil($i/$nbr_par_page);
        $tpage[$i] = $page ;
    }

    if ($page == $ppage)
    {
        if ($col_simple    != "Oui")
        {
            if ($j == ( $nbr_colonne ) )
            {
?>
  <tr>
    <td>
      <center><a href="javascript:openPopWin('<?php echo($RepGrosseImages.$image); ?>',<?php echo($rwidth.",".$rheight); ?>,'','cen','cen')">
<?php
                if ($thumb == "Oui")
                {
?>
        <img src='thumb/<?php echo($image); ?>' border="0" alt="<?php echo($image*$width*$height); ?>" width="<?php echo($pourcentage_reduce); ?>"><br>
<?php
                }
                else
                {
?>
        <img src="<?php echo($RepGrosseImages.$image); ?>" border=0 alt="<?php echo($image*$width*$height); ?>" width="<?php echo($pourcentage_reduce); ?>"><br>
<?php
                }
?>
        <font size="-2"><?php echo($image); ?></font></a>
      </center>
    </td>
  </tr>
<?php
                $j = 1;
            }
            else
            {
?>
  <tr>
    <td>
      <center><a href="javascript:openPopWin('<?php echo($RepGrosseImages.$image); ?>',<?php echo($rwidth .",". $rheight); ?>,'','cen','cen')">
<?php
                if ($thumb == "Oui")
                {
?>
      <img src="thumb/<?php echo($image); ?>" border="0" alt="<?php echo($image*$width*$height); ?>" width="<?php echo($pourcentage_reduce); ?>"><br>
<?php
                }
                else
                {
?>
      <img src="<?php echo($RepGrosseImages.$image); ?>" border="0" alt="<?php echo($image*$width*$height); ?>" width="<?php echo($pourcentage_reduce); ?>"><br>
<?php
                }
?>
      <font face="Arial,Helvetica" size=-2><?php echo($image); ?></font></a>
      </center>
    </td>
  </tr>
<?php
                $j = $j + 1;
            }
        }
        else
        {
?>
  <tr>
    <td>
      <div align="center">
        <a href="javascript:openPopWin('<?php echo($RepGrosseImages.$image); ?>',<?php echo($rwidth.",".$rheight); ?>,'','cen','cen')">
<?php
            if ($thumb == "Oui")
            {
?>
        <img src="thumb/<?php echo($image); ?>" border="0" alt="<?php echo($image*$width*$height); ?>" width="50">
<?php
            }
            else
            {
?>
        <img src="<?php echo($RepGrosseImages.$image); ?>" border="0" alt="<?php echo($image*$width*$height); ?>" width="50">
<?php
            }
?>
        </a>
      </div>
    </td>
    <td>
      <div align="center"><font size="1"><?php echo($image); ?></font></div>
    </td>
    <td>
      <div align="center"><font size="1"><?php echo($rwidth); ?></font></div>
    </td>
    <td>
      <div align="center"><font size="1"><?php echo($rheight); ?></font></div>
    </td>
  </tr>
<?php
            $j = $j + 1;
        }
    } //if
} //for
?>
</table>
<br>
<center>
<?php
$sval = -1;
while (list ($key, $val) = each ($tpage))
{
    if ($sval != $val)
    {
?>
<b><font size="1">[
<a href="index.php?page=climb&ppage=<?php echo($val); ?>"><?php echo($val); ?></a>
]</b>
<?php
        $sval = $val;
    }
}
?>
</center>
Ensuite, on a pas nécessairement besoin de tout ce code, on a juste besoin de voir la partie qui te sert à trier. J'avoue que je n'ai pas bien suivi tout le raisonnement du code.
Codez en pensant que celui qui maintiendra votre code est un psychopathe qui connait votre adresse :axe:

Mammouth du PHP | 19672 Messages

03 oct. 2005, 09:59

Bon, après une nuit de sommeil, ça passe mieux, voici une proposition, je te laisse le soin de tester, j'ai optimisé quelque peu et ajouté une fonction qui devrait permettre de trier dans le sens alphabétique par défaut, alphabétique inverse, date d'ajout ou date inverse : il te faudra donc rajouter un paramètre de tri, à priori dans l'url et le récupérer via $_GET.

J'ai aussi coupé dans le gras du code HTML pour simplifier:
<?php
$col_simple   = "non";     // Si $col_simple == Oui Alors presentation speciale sur une colonne
                           // avec gestion des pages, on affiche par page le nbr_colonne * nbre_ligne
                           // Si $col_simple != Oui Alors on affiche une mosaique en tenant compte de
                           // nbr_colonne et nbr_ligne

$nbr_colonne  =5;
$nbr_ligne    =3;

$image_de_fond       = "#ffffff";
$thumb               = "thumb/"; // Si Oui, on utilise le repertoire /thumb pour la mosaique
$pourcentage_reduce  = 60;
$RepGrosseImages     = "climb/images/";
$faire_miniature     = "Non"; //En developpement
//Taille de l'extension = 3 // 3 : pour jpg 4 : jpeg
///////////////////////////////////////////////////////////////////////////////////////////
/* Fonction de tri de fichier par date de dernière modification */
function getDateFile($files, $inverse = false)
{
    $tableau = array();
    foreach($files as $file)
    {
        $tableau[filemtime($file)] = array($file);
    }
    $fichiers = array();
    $fichiers = $inverse ? ksort($tableau) : krsort($tableau);
    /* On recrée le tableau d'origine */
    $files = array();
    foreach($fichiers as $fichier)
    {
        $files[] = $fichier;
    }
    return $files;
}

function GetFileList( $dirname=".", $ordre = null)
{
    $files = array();

    $dir = opendir( $dirname );
    while( $file = readdir( $dir ) )
    {
        if (eregi("jpg$",$file) ||
            eregi("jpeg$",$file) ||
            eregi("png$",$file) ||
            eregi("gif$",$file))
        {
            $files[] = $file;
        }
    }
    if(!isset($ordre))
    {
        sort($files);
    }
    else
    {
        switch($ordre)
        {
            case "alpha_inverse" : 
                rsort($files);
            break;
            case "date_ajout" : 
                $fichiers = getDateFile($files, false); 
                $files = array(); 
                $files = $fichiers;
            break;
            case "date_inverse" : 
                $fichiers = getDateFile($files, true); 
                $files = array(); 
                $files = $fichiers;
            break;
            default: 
                sort($files);
        }
    }
    return $files;
}
?>
<HTML>
<HEAD>
  <TITLE></TITLE>
  <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1"><style type="text/css">
<!--
body {
    font-family: Verdana, Arial, Helvetica, sans-serif;
}
a:link {
    color: #FFFFFF;
    text-decoration: none;
}
a:visited {
    text-decoration: none;
    color: #FFFFFF;
}
a:hover {
    text-decoration: underline;
}
a:active {
    text-decoration: none;
}
body,td,th {
    color: #FFFFFF;
}
body {
    background-color: #000000;
}
-->
</style><body alink="#FFFFFF" background="<?php echo $image_de_fond; ?>">
</HEAD>
<SCRIPT Language="JavaScript">  
<!--
var popWin = null
var winCount = 0
var winName = "popWin"

function openPopWin(winURL, winWidth, winHeight, winFeatures, winLeft, winTop)
{
    var d_winLeft = 0
    var d_winTop = 0
    winName = "popWin" + winCount++
    closePopWin()
    if (openPopWin.arguments.length >= 4)
    {
        winFeatures = "," + winFeatures
    }
    else
    {
       winFeatures = ""
    }
    if (openPopWin.arguments.length == 6)
    {
        winFeatures += getLocation(winWidth, winHeight, winLeft, winTop)
    }
    else
    {
        winFeatures += getLocation(winWidth, winHeight, d_winLeft, d_winTop)
    }
    popWin = window.open(winURL, winName, "width=" + winWidth + ",height=" + winHeight + winFeatures)
}

function closePopWin()
{
    if (navigator.appName != "Microsoft Internet Explorer" || parseInt(navigator.appVersion) >=4)
    {
        if(popWin != null)
        {
            if(!popWin.closed)
            {
                popWin.close()
            }
        }
    }
}

function getLocation(winWidth, winHeight, winLeft, winTop)
{
    return ""
}
//-->
</SCRIPT>
<SCRIPT Language="JavaScript1.2">
<!--
function getLocation(winWidth, winHeight, winLeft, winTop)
{
    var winLocation = ""
    if (winLeft < 0)
    {
        winLeft = screen.width - winWidth + winLeft
    }
    if (winTop < 0)
    {
        winTop = screen.height - winHeight + winTop
    }
    if (winTop == "cen")
    {
        winTop = (screen.height - winHeight)/2 - 20
    }
    if (winLeft == "cen")
    {
        winLeft = (screen.width - winWidth)/2
    }
    if (winLeft>0 & winTop>0)
    {
        winLocation =  ",screenX=" + winLeft + ",left=" + winLeft + ",screenY=" + winTop + ",top=" + winTop
    }
    else
    {
        winLocation = ""
    }
    return winLocation
}
//-->
</SCRIPT>
<p>
<center>
</center>
</p>
<?
if ($col_simple != "Oui")
{
?>
<table border="0" align="center" cellspacing="0" cellpadding="6">
<?php
}
else
{
    $param = " width=\"600\" border=\"1\" cellspacing=\"0\" cellpadding=\"2\" align=\"center\"";
?>
<table width="600" border="1" cellspacing="0" cellpadding="2" align="center">
  <tr bgcolor="#999999">
    <td>
      <div align="center"><font size="2">Apercu</font></div>
    </td>
    <td>
      <div align="center"><font size="2">Nom</font></div>
    </td>
    <td>
      <div align="center"><font size="2">Largeur</font></div>
    </td>
    <td>
      <div align="center"><font size="2">Hauteur</font></div>
    </td>
  </tr>
<?php
}
$imagelist = GetFileList($RepGrosseImages);

$nbr_par_page    = $nbr_colonne * $nbr_ligne;
$nbr_tot         = count($imagelist);
$debut           = 1;
$j               = 1;
$fin             = $nbr_par_page;

$ppage = isset($_GET['ppage']) ? $_GET['ppage'] : 1;

for($i = $debut; $i < $nbr_tot + 1; $i++)
{
    $image = $imagelist[$i-1];

    if (file_exists($RepGrosseImages.$image))
    {
        $size      = getimagesize($RepGrosseImages.$image);
        $width     = $size[0];
        $height    = $size[1];
        $rwidth    = $size[0]+20;
        $rheight   = $size[1]+20;
        $page      = ceil($i/$nbr_par_page);
        $tpage[$i] = $page ;
    }

    if ($page == $ppage)
    {
?>
  <tr>
    <td>
      <div align="center">
        <a href="javascript:openPopWin('<?php echo($RepGrosseImages.$image); ?>',<?php echo($rwidth .",". $rheight); ?>,'','cen','cen')">
<?php
        if ($col_simple    != "Oui")
        {
            if ($thumb == "Oui")
            {
?>
        <img src='thumb/<?php echo($image); ?>' border="0" alt="<?php echo($image*$width*$height); ?>" width="<?php echo($pourcentage_reduce); ?>"><br>
<?php
            }
            else
            {
?>
        <img src="<?php echo($RepGrosseImages.$image); ?>" border=0 alt="<?php echo($image*$width*$height); ?>" width="<?php echo($pourcentage_reduce); ?>"><br>
<?php
            }
?>
        <font size="-2"><?php echo($image); ?></font></a>
      </div>
    </td>
  </tr>
<?php
            if ($j == ( $nbr_colonne ) )
            {
                $j = 1;
            }
            else
            {
                $j++;
            }
        }
        else
        {
            if ($thumb == "Oui")
            {
?>
        <img src="thumb/<?php echo($image); ?>" border="0" alt="<?php echo($image*$width*$height); ?>" width="50">
<?php
            }
            else
            {
?>
        <img src="<?php echo($RepGrosseImages.$image); ?>" border="0" alt="<?php echo($image*$width*$height); ?>" width="50">
<?php
            }
?>
        </a>
      </div>
    </td>
    <td>
      <div align="center"><font size="1"><?php echo($image); ?></font></div>
    </td>
    <td>
      <div align="center"><font size="1"><?php echo($rwidth); ?></font></div>
    </td>
    <td>
      <div align="center"><font size="1"><?php echo($rheight); ?></font></div>
    </td>
  </tr>
<?php
            $j++;
        }
    } //if
} //for
?>
</table>
<br>
<center>
<?php
$sval = -1;
while (list ($key, $val) = each ($tpage))
{
    if ($sval != $val)
    {
?>
<b><font size="1">[
<a href="index.php?page=climb&ppage=<?php echo($val); ?>"><?php echo($val); ?></a>
]</b>
<?php
        $sval = $val;
    }
}
?>
</center>
Codez en pensant que celui qui maintiendra votre code est un psychopathe qui connait votre adresse :axe:

diab
Invité n'ayant pas de compte PHPfrance

03 oct. 2005, 19:04

Je te remercie de ta réponse, mais sache que je suis vraiment un débutant un php...

J'ai bien compris ce que tu voulais dire à propos du parametre que je dois ajouter dans l'url... Mais le probleme c'est que je sais pas ou et comment je cale le $_get dans le code et quelle parametre ajouter dans l'url...

merci de ton aide précieuse....

Mammouth du PHP | 19672 Messages

03 oct. 2005, 19:11

Ça veut dire que tu devras rajouter des liens offrant un tri ou un autre, mais les liens devront être dynamiques et inclure le cas échant la page en cours et ajouter un parametre en plus. Grossomodo, ce sera un ien du genre: tapage.php?ppage=2&tri=date_inverse pour dans ce cas afficher la page deux mais avec un tri par date du plus récent au plus ancien
Si tu ne mets pas de second paramètre, alors le tri se fera par défaut en ordre alphabétique.
Codez en pensant que celui qui maintiendra votre code est un psychopathe qui connait votre adresse :axe:

diab
Invité n'ayant pas de compte PHPfrance

03 oct. 2005, 20:19

ok je vois mais à quoi correspond, amp;tri= ?
puisqu'il n'est pas dans le code... du tout quand je tape l'adresse avec ce parametre ca marche pas...

(je suis lourd peut etre :)

Mammouth du PHP | 19672 Messages

03 oct. 2005, 20:45

non, au lieu de mettre "&", je mets "&", c'est la même chose, mais c'est une question de validité de code de sortie, ça ne change strictement rien au fonctionnement.
Codez en pensant que celui qui maintiendra votre code est un psychopathe qui connait votre adresse :axe: