3v4l.org

run code in 300+ PHP versions simultaneously
<?php /** * Generating Gallery Vieuw * * Generating a simple gallery overview, * with Planned !possible extended MySQL Description support * * PHP Version 5 * * @category Gallery/Images * @author Diederick Bruin DDABruin@gmail.com * @copyright 2014 http://DiederickBruin.nl/ * */ class Gallery { private $MySQL_Host, $MySQL_Database, $MySQL_User, $MySQL_Password, $MySQL_Table; public static function GenerateCSS($folder = "img/",$imgclass = "fotodiv") { foreach(glob($folder."*.{jpg,png,gif,jpeg,ico}", GLOB_BRACE) as $Path) { $Bestand = str_replace($folder, "", $Path);//stip folder $Bestand = str_replace(".", "_", $Bestand);//remove dots to genereate classname $rstring .= ".img_$Bestand:hover + .desc_$Bestand"; $rstring .= "{display: block;} \n"; /*$rstring .= ".desc_$Bestand:hover + .desc_$Bestand"; //unnuset figure out howto code $rstring .= "{display: block;} \n";*/ } return $rstring; } public static function Generate($folder = "img/",$imgclass = "fotodiv") { foreach(glob($folder."*.{jpg,png,gif,jpeg,ico}", GLOB_BRACE) as $Path) { $Bestand = str_replace($folder, "", $Path); $Bestand = str_replace(".", "_", $Bestand); $rstring .= '<div class="'.$imgclass.'">'; $rstring .= '<img class="img_'.$Bestand.'" src="'.$Path.'">'; $rstring .= '<div class="desc_'.$Bestand.'"><p>'.$Bestand.'</p></div></div>';// functie GDescription gebruiken om de beschrijving te krijgen } return $rstring; } /** * * Hieronder niet afgemaakt */ private function GDescription($Path) //private omdat hij alleen binnen de class word gebruikt om de description te vullen voor nu { //$Bestand = str_replace("img/", "", $Path); haal met path uit database $MySQL_Connect = mysqli_connect($MySQL_Host, $MySQL_User, $MySQL_Password, $MySQL_Database); if (mysqli_connect_errno()) { echo "Failed to connect to MySQL: " . mysqli_connect_error(); } $result = mysqli_query($MySQL_Connect,"SELECT * FROM `$MySQL_Table` WHERE File = '$Path'"); $rstring = mysqli_fetch_array($result); mysqli_close($MySQL_Connect); return $rstring['Description']; } } ?>

preferences:
52.33 ms | 402 KiB | 5 Q