19. oktober 2004 - 08:50Der er
21 kommentarer og 1 løsning
Galleri som tæller/viser forkert vej
<? //---- Settings Start ---\\ // Image Information $imageWidth=110; $imageHeight=80;
// Table Layout $rows=3; $cols=3;
//Image path $libery="cimages/"; // remember to finish with /
// Settings Stop----------//
$viewNum=$cols*$rows; if(!$firstImage){ // so it works if you just enter gcichlider.php3 and show the pictures without having to define the variables in the path $firstImage=1; } function getImages($firstImage){ global $viewNum, $imageWidth, $imageHeight,$cols,$libery; //insures that the function gets the variables $handle=opendir($libery); //opens directory while($file=readdir($handle)){ // reads the directory $extension=substr($file,-4); // gets the extension of the files if(($extension == ".jpg") || ($extension == ".gif") || ($extension == ".png") ){ // checks for image files $all[]=$file; //adds positive results to the archive } } $colscounter=0; // variable that controls the tablebuilding system below $firstImage--; // variable that insures that the first image is being showed. Case: It looks best if the links begins with 1 but the array begins with 0 if(isset($all)){ // if array is set build the table print "<table>"; for($i=$firstImage; $i < $firstImage+$viewNum; $i++){ if($all[$i]){ // checks for rinning dry of imges if($i==$firstImage + $colscounter*$cols){ // if true: new row $colscounter++; print "<tr>"; } // add the image print "<td><a href='".$libery."".$all[$i]."'><img src='".$libery."".$all[$i]."' border='0' width='$imageWidth' height='$imageHeight' alt='Klik for at forstørre'></a></td>"; } else{ // stop if no more images break; } } print "</table><br>"; $num=count($all); //number of pictures in actual libery makeList($num); // function to make the links list } else{ print "Der var desværre ingen billeder i dette bibliotek<br><a href='java script:history.back()'>Go Back</a>"; } } function makeList($num){ global $libery, $firstImage, $viewNum; //insures that the function gets the variables $numLinks = $num / $viewNum; // finds the number og links to be maked for($a=0; $a < $numLinks;$a++){ $start=$a*$viewNum+1; //adds 1 because then the links begins with ex. number 1-10 and 11-20 instead of 0-10 and 10-20 $finish=$a*$viewNum+$viewNum; if($finish>$num){ // insures that the final link returns the right amount of pictures instead of to much $finish=$num; } if(($firstImage >= $start) && ($firstImage < $a * $viewNum+$viewNum)){ // if true: makes no link because you already are on the page print "$start - $finish</a> "; } else{ // makes the link print "<a href='gcichlider.php3?libery=$libery&firstImage=$start'>$start - $finish</a> "; } } } ?>
Dette viser billeder jeg smider i en mappe og derefter opretter den 115-125 osv men jeg vil have de nyeste billeder til vise først når man kommer ind på siden ! P.s dette er en functions.inc fil
I dette særtema ser vi på, hvordan cloud og AI bliver fundamentet for virksomhedernes digitale forretning, og hvordan de nye muligheder for automatisering og forretningsværdi kan udnyttes uden at miste overblik, sikkerhed og menneskelig kontrol.
function getImages($firstImage){ global $viewNum, $imageWidth, $imageHeight,$cols,$libery; //insures that the function gets the variables $handle=opendir($libery); //opens directory while($file=readdir($handle)){ // reads the directory $extension=substr($file,-4); // gets the extension of the files if(($extension == ".jpg") || ($extension == ".gif") || ($extension == ".png") ){ // checks for image files $all[]=$file; //adds positive results to the archive } } ksort( $all ); // eller krsort for revers sort
her sortere jeg selv, men det kræver at der kun er tal i billedernes navne.
Lettere at gi det hele end at forklare:
<?php
//---- Settings Start ---\\ // Image Information $imageWidth=110; $imageHeight=80;
// Table Layout $rows=3; $cols=3;
//Image path $libery="cimages/"; // remember to finish with /
// Settings Stop----------// $slut_tr=""; $viewNum=$cols*$rows; if(!$firstImage){ // so it works if you just enter gcichlider.php3 and show the pictures without having to define the variables in the path $firstImage=1; } function getImages($firstImage){ global $viewNum, $imageWidth, $imageHeight,$cols,$libery; //insures that the function gets the variables $handle=opendir($libery); //opens directory while($file=readdir($handle)){ // reads the directory $extension=substr($file,-4); // gets the extension of the files if(($extension == ".jpg") || ($extension == ".gif") || ($extension == ".png") ){ // checks for image files $all[]=$file; //adds positive results to the archive } } usort($all, "cmp"); $colscounter=0; // variable that controls the tablebuilding system below $firstImage--; // variable that insures that the first image is being showed. Case: It looks best if the links begins with 1 but the array begins with 0 if(isset($all)){ // if array is set build the table print "<table>\n"; for($i=$firstImage; $i < $firstImage+$viewNum; $i++){ if($all[$i]){ // checks for rinning dry of imges if($i==$firstImage + $colscounter*$cols){ // if true: new row $colscounter++; print $slut_tr."<tr>\n"; $slut_tr="</tr>\n"; } // add the image print "<td><a href='".$libery."".$all[$i]."'><img src='".$libery."".$all[$i]."' border='0' width='$imageWidth' height='$imageHeight' alt='Klik for at forstørre $i $all[$i]'></a></td>\n"; } else{ // stop if no more images break; } } print "</tr>\n</table>\n<br>\n"; $num=count($all); //number of pictures in actual libery makeList($num); // function to make the links list } else{ print "Der var desværre ingen billeder i dette bibliotek<br><a href='java script:history.back()'>Go Back</a>"; } } function makeList($num){ global $libery, $firstImage, $viewNum; //insures that the function gets the variables $numLinks = $num / $viewNum; // finds the number og links to be maked for($a=0; $a < $numLinks;$a++){ $start=$a*$viewNum+1; //adds 1 because then the links begins with ex. number 1-10 and 11-20 instead of 0-10 and 10-20 $finish=$a*$viewNum+$viewNum; if($finish>$num){ // insures that the final link returns the right amount of pictures instead of to much $finish=$num; } if(($firstImage >= $start) && ($firstImage < $a * $viewNum+$viewNum)){ // if true: makes no link because you already are on the page print "$start - $finish</a> "; } else{ // makes the link print "<a href='gcichlider.php3?libery=$libery&firstImage=$start'>$start - $finish</a> "; } } }
Tilladte BB-code-tags: [b]fed[/b] [i]kursiv[/i] [u]understreget[/u] Web- og emailadresser omdannes automatisk til links. Der sættes "nofollow" på alle links.