Zum Inhalt springen
View in the app

A better way to browse. Learn more.

Fachinformatiker.de

A full-screen app on your home screen with push notifications, badges and more.

To install this app on iOS and iPadOS
  1. Tap the Share icon in Safari
  2. Scroll the menu and tap Add to Home Screen.
  3. Tap Add in the top-right corner.
To install this app on Android
  1. Tap the 3-dot menu (⋮) in the top-right corner of the browser.
  2. Tap Add to Home screen or Install app.
  3. Confirm by tapping Install.

[PHP] ordner auslesen und in menü legen

Empfohlene Antworten

Veröffentlicht

moin moin

hat wer ne idee wie ich ein ordner mit bildern auslese und die dateinamen in einem menüfeld wiedergebe?

mfg logimann

Hab mal einen Ausschnitt aus unserer Intranetseite für deine Bedürfnisse gekürzt.


<?
$handle=opendir('Bilderverzeichnis');
$datei=array();
while ($file = readdir ($handle)) {
/* Der Befehl readdir würde auch "." und ".." mit ausgeben,
deshalb wird eine Fallunterscheidung durchgeführt. Ausserdem wird per
substr_count ermittelt, ob der Dateiname .jpg enthält, es sich also
um ein Bild handelt.*/
if ($file != "." && $file != ".." && substr_count($file,".jpg")>0)
{
$datei[]=$file;
}
}
closedir($handle);
arsort($datei);
reset($datei);
foreach($datei as $filename){
echo "<div>$filename</div>" //Musst du halt noch formatieren.
}
?>
[/PHP]

Wenn du noch andere Formate als .jpg hast, musst du die bei substr_count noch anfügen. Wenn du die Beschreibungen zu den Funktionen suchst, schau auf Php.net.

ok danke , aber wie geb ich das jetzt in ein downmenü?

Hatte doch geschrieben, das du das noch formatieren musst.:beagolisc

Das ginge mit Javascript.

Füge im Head des Dokuments folgendes ein:


<script language="JavaScript" type="text/javascript">

<!--

function go(){

if (document.links.select1.options[document.links.select1.selectedIndex].value != "") {

window.location.href = document.links.select1.options[document.links.select1.selectedIndex].value

}                       

}

//-->

</script>

Und folgendes statt der foreach-Schleife, die ich da vorher stehen hatte.


<?
...
?>
<FORM NAME="links">
<SELECT onchange=go() size=1 name=select1>
<option value="">Bilderliste: </option>
<?
foreach($datei as $filename){
echo "<option value=\"http://www.deineseite.de/Bilderverzeichnis/$filename\">$filename</option>";
?>
</SELECT>
</FORM>
[/PHP]

Normalerweise mach ich sowas ja nicht, aber mir war grad langweilig.:rolleyes:

Archiv

Dieses Thema wurde archiviert und kann nicht mehr beantwortet werden.

Configure browser push notifications

Chrome (Android)
  1. Tap the lock icon next to the address bar.
  2. Tap Permissions → Notifications.
  3. Adjust your preference.
Chrome (Desktop)
  1. Click the padlock icon in the address bar.
  2. Select Site settings.
  3. Find Notifications and adjust your preference.