Andreas: virtueller Rundgang

Beitrag lesen

Hallo,

und wenn Du jetzt noch Definitionen, Berechnungen und Ausgaben sauber voneinander trennst, dann hast Du DEN Erfolg...

leichter gesagt als getan.
Habe mein Code noch weiter vereinfacht und besser Strukturiert. Aber wie ich die Berechnungen etc. von der Ausgabe trennen kann fällt mir ad hoc nicht ein.

Mein Code: wie du siehst übergebe ich jetzt das komplett Array des zu ladenden Bildes.

if (!isset($action))
 $action = 'b1';
$path = 'gfx/rundgang/';
$num = substr($action,1,strlen($action)-1);
$bild1 = array(0,1,0,1,0,0,0,2,0,3,0,0,"1b1.jpg");
$bild2 = array(0,0,0,0,1,0,0,0,0,0,1,0,"1b2.jpg");
$bild3 = array(0,0,1,0,1,0,0,0,4,0,1,0,"1b3.jpg");
$bild4 = array(0,0,0,0,1,0,0,0,0,0,3,0,"1b4.jpg");
$bild5 = array(1,1,0,0,1,0,2,4,0,0,3,0,"1b5.jpg");
echo '
<table border="0" cellspacing="0" cellpadding="0">
 <tr><td align="center" valign="top">';
 echo '<img src="'.$path.${'bild'.$num}[12].'" alt="" width=300></td></tr>';
 navi(${'bild'.$num});
echo '</table>';

function navi($arr){
 Global $path;
 $attib = 'alt="" width="32" height="32" border="0" hspace="2" vspace="2"';
 $url = 'rundgang.php?action=b';
 For ($i=0; $i<6; $i++){
  ${'b'.($i+1)} = $arr[$i];
 }
 For ($i=6;$i<12;$i++){
  ${'a'.($i-5)} = $arr[$i];
 }
 echo '
 <tr><td align="center" valign="top">';
 if ($b1==1) echo '<a href="'.$url.$a1.'">'; echo '<img src="'.$path.'bild1'; if($b1==1) echo 'a'; echo '.gif" '.$attib.'></a>';
 if ($b2==1) echo '<a href="'.$url.$a2.'">'; echo '<img src="'.$path.'bild2'; if($b2==1) echo 'a'; echo '.gif" '.$attib.'></a>';
 if ($b3==1) echo '<a href="'.$url.$a3.'">'; echo '<img src="'.$path.'bild3'; if($b3==1) echo 'a'; echo '.gif" '.$attib.'></a>';
 echo '</td></tr><tr><td align="center" valign="top">';
 if ($b4==1) echo '<a href="'.$url.$a4.'">'; echo '<img src="'.$path.'bild4'; if($b4==1) echo 'a'; echo '.gif" '.$attib.'></a>';
 if ($b5==1) echo '<a href="'.$url.$a5.'">'; echo '<img src="'.$path.'bild5'; if($b5==1) echo 'a'; echo '.gif" '.$attib.'></a>';
 if ($b6==1) echo '<a href="'.$url.$a6.'">'; echo '<img src="'.$path.'bild6'; if($b6==1) echo 'a'; echo '.gif" '.$attib.'></a>';
 echo '</td></tr>';