
Meine Flickr-Fotos, die hier sowohl links als auch rechts auf dieser Seite zu sehen sind, wechseln bei jedem neu laden der Seite. Welches Bild angezeigt wird, ist durch eine Zufallszahl bestimmt. Die Fotos werden direkt von Flickr geladen, dort gibt es unterschiedliche größen zur Auswahl. Das PHP-Script dafür sieht so aus:
<?php
// Erzeugt eine Zufallszahl und weist den Variablen $link und $foto entsprechend
unterschiedliche Werte zu.
srand ((double)microtime()*20000);
$zufall = rand(1,3);
if($zufall == 1)
{
$link = "http://www.flickr.com/...";
$foto = "http://farm2.static.flickr.com/...";
}
elseif($zufall == 2)
{
$link = "http://www.flickr.com/...";
$foto = "http://farm2.static.flickr.com/...";
}
elseif($zufall == 3)
{
$link = "http://www.flickr.com/...";
$foto = "http://farm2.static.flickr.com/...";
}
else
{
$link = "http://www.flickr.com/...";
$foto = "http://farm2.static.flickr.com/...";
}
echo '<a target="_blank" href="',$link,'"title="Fotorotation"><img width="240" height="182" class="bild_im_text_rechts" align="right" src="',$foto,'" alt="Foto
von Marvin Nassowitz" />';
?>
<?
switch ($auswahl = rand(1,3)) {
case $auswahl = 1:
$foto='...';
$link='...'; break;
case $auswahl = 2:
$foto='...';
$link='...'; break;
case $auswahl = 3:
$foto='...';
$link='...'; break;
default:
$foto='...';
$link='...';
}
?>