Modifier un code sur une gallerie

cs_mike501 Messages postés 88 Date d'inscription dimanche 1 mai 2005 Statut Membre Dernière intervention 3 septembre 2007 - 29 juil. 2005 à 19:39
cs_mike501 Messages postés 88 Date d'inscription dimanche 1 mai 2005 Statut Membre Dernière intervention 3 septembre 2007 - 31 juil. 2005 à 13:54
bonjour, je vien de trouver une galerie a mon gout mais le souci c est que les image ce mette toute sur la meme page estce que quelq un pourrai m aider a modifier le code ce que je voudrai c est limiter le nombre d image sur une page

Voici le code :

<?php
error_reporting(E_ALL);
function thumb($photo,$grand,$destination){


$fichierSource = $photo;


$source = ImageCreateFromJpeg("./img/".$fichierSource);


$largeurSource = imagesx($source);
$hauteurSource = imagesy($source);


$rapport_dim= $largeurSource / $hauteurSource;


if ( $largeurSource >= $hauteurSource ) {
$largeurDestination = $grand;
$hauteurDestination = $largeurDestination / $rapport_dim;
}
else {
$hauteurDestination = $grand;
$largeurDestination = $hauteurDestination * $rapport_dim;
}


$im = ImageCreateTrueColor ($largeurDestination, $hauteurDestination)
or die ('Erreur lors de la création de l\'image');


ImageCopyResampled($im, $source, 0, 0, 0, 0, $largeurDestination, $hauteurDestination, $largeurSource, $hauteurSource);



ImageJpeg ($im, "$destination/$fichierSource");



}


function knowdir($path){


$path=dirname($path);


$path=strrchr($path,"/");
return $path;
}


include ('../inc/config.php');


$dir=knowdir($_SERVER['PHP_SELF']);
$image_path=$path."galerie/$dir" ;


//création du tableau des photos
$dir_connect=opendir("./img");


$table_id=1;


while($file=readdir($dir_connect)) {
$photos_tab[$table_id]=$file;
$table_id++;
}


sort($photos_tab);


$dir_sans=str_replace(' ','%20',$dir);


echo '

<center>',"\n";
echo '[',$path,$nom_index,'galerie',$dir_sans,' Ajouter une nouvelle photo]',"\n";
echo '<table border="0" width="100%"><tr>',"\n";


if ( ! isset($_GET['photo_id'])) {


$table_read=2;
echo '<table color="',$table_color,'"><tr>';



while ( @$file_photo=$photos_tab[$table_read] ) {


if (!$redim) {
$dim_thumb='';
}
else {
$hauteur_thumb1=3/4 * $dim_thumb1;
$dim_thumb='width="'.$dim_thumb1.'" height="'.$hauteur_thumb1.'"';
}
echo '<td>',"\n";
echo '<center>[',$path,$nom_index,'galerie',$dir,'/index.php?photo_id=',$table_read,' ',"\n";
echo ']<center></td>',"\n\n\n";


if (!is_file('./thumb/'.$file_photo)) {
thumb($file_photo,$dim_thumb1,'./thumb');


}


if (!is_file('./thumb2/'.$file_photo)) {
thumb($file_photo,$dim_thumb2,'./thumb2');
}


if ( intval(($table_read+($nb_photo_col-1))/$nb_photo_col) == ($table_read+($nb_photo_col-1))/$nb_photo_col and $table_read+2!=$nb_photo_col) {
echo '</tr><tr>';
}


$table_read ++;
}



}
else {
$photo_id=$_GET['photo_id'];



$file_photo=$photos_tab[$photo_id];



if (!is_file("./thumb2/$file_photo")) {
thumb($file_photo,$dim_thumb2,"./thumb2");
}
$link_file=str_replace(" ","%20",$file_photo);
echo '<td><center>[',$path,$nom_index,'galerie',$dir,'/index.php?photo_id=',$photo_id,' ',"\n";
echo ']',"\n";
echo '<center></td>',"\n";



if (@ $file_photo=$photos_tab[$photo_id+1] ) {


if (!is_file('./thumb/'.$file_photo)) {
thumb($file_photo,$dim_thumb1,'./thumb');
}
$photos_suiv=$photo_id+1;


echo '<td width="20%"><center>',"\n";
echo '<center></td>',"\n";


}
}
?>

4 réponses

mcjoedassin Messages postés 196 Date d'inscription mercredi 27 juillet 2005 Statut Membre Dernière intervention 2 septembre 2005
29 juil. 2005 à 21:38
peut-être peux tu essayer de remplacer



while($file= readdir($dir_connect))

par

while(($file=readdir($dir_connect)) && ($table_id < 10))



mais peut-être que tu préfèrerais remplacer



while ( @$file_photo =$photos_tab[$table_read] )

par

while ((@$file_photo=$photos_tab[$table_read]) && ($table_read < 10))



je pense que cette dernière solution correspond plus à tes besoins.

Sinon, cherche les autres while dans le texte !
0
cs_mike501 Messages postés 88 Date d'inscription dimanche 1 mai 2005 Statut Membre Dernière intervention 3 septembre 2007
30 juil. 2005 à 20:21
sa ne marche ps sa fai une erreur
0
mcjoedassin Messages postés 196 Date d'inscription mercredi 27 juillet 2005 Statut Membre Dernière intervention 2 septembre 2005
30 juil. 2005 à 20:39
change

$table_read=2;



en

$table_read=10;



pour voir



sinon, tu n'as plus qu'à comprendre le code par toi même...
0
cs_mike501 Messages postés 88 Date d'inscription dimanche 1 mai 2005 Statut Membre Dernière intervention 3 septembre 2007
31 juil. 2005 à 13:54
ca ne marche toujour pas

quelq un d autre pourrai m aidez, je suiis desesperer
0
Rejoignez-nous