![]() |
![]() |
|
|
|||||||
| Programmierung Rat & Tat für Programmierer |
![]() |
|
|
Themen-Optionen | Ansicht |
|
|
|
|
#1 | |
|
Inventar
![]() Registriert seit: 03.09.2000
Beiträge: 4.010
|
Zitat:
*grübel*
____________________________________
Für ein friedliches Zusammenleben im Forum werde ich ab sofort keine Trolle mehr füttern, und zwar unabhängig von der Sinnhaftigkeit ihrer Wortmeldungen. |
|
|
|
|
|
|
#2 |
|
Inventar
![]() |
Geht natürlich noch einfacher mit Modulo (wobei die 100 natürlich mit der Gesamtanzahl deiner Datensätze ersetzt werden muss)
PHP-Code:
PHP-Code:
PHP-Code:
lg
____________________________________
„Das menschliche Gehirn ist eine großartige Sache. Es funktioniert vom Moment der Geburt an – bis zu dem Zeitpunkt, wo du aufstehst, um eine Rede zu halten.“ Mark Twain "Windle shook his head sadly. Four exclamation marks, the sure sign of an insane mind" Reaper Man, Terry Pratchett |
|
|
|
|
|
#3 |
|
Veteran
![]() Registriert seit: 07.11.2003
Alter: 51
Beiträge: 393
|
auf 0 setzen, damits wieder 1 wird bei nächsten durchlauf ? ich hab das so gemacht, weil ich keine weitere schleife hinenipacken wollt, also hier is der ganze code, ich check nicht wo der fehler is: Code:
<html> <link rel="shortcut icon" href="favicon.ico" type="image/vnd.microsoft.icon" /> <link rel="icon" href="favicon.ico" type="image/vnd.microsoft.icon" /> <head> <link rel="stylesheet" type="text/css" href="css.css"> <title> Index of / </title> </head> <body> <?php // open the current directory by opendir $handle=opendir("."); $zaehler=0; while (($file = readdir($handle))!==false) { $zaehler=$zaehler+1; if ($zaehler==1){$colour='rot';} if ($zaehler==2){$colour='green';} if ($zaehler==3){$colour='blue';} if ($file !=='files' && $file !=='private' && $file !=='mail' && $file !=='sommer2008'){ echo '<p><a class="'.$colour.'" href="'.$file.'"> </a>'; echo '<a href="'.$file.'">'.$file.'</a>'; } if ($zaehler==3){$zaehler=0;} } closedir($handle); ?> </table> </body> </html> ![]() |
|
|
|
|
|
#4 |
|
Veteran
![]() Registriert seit: 07.11.2003
Alter: 51
Beiträge: 393
|
ich hab jetzt ein echo $zaehler reingetan und bin draufgekommen, das problem is nicht dass er falsch zählt, sondern dass er bei zweiten durchgang und bei jedem übernächsten bei 2 und 3 keine farbe zugeordnet..
Code:
<head>
<link rel="stylesheet" type="text/css" href="css.css">
<title>
Index of /
</title>
</head>
<body>
<?php
// open the current directory by opendir
$handle=opendir(".");
$zaehler=0;
while (($file = readdir($handle))!==false) {
$zaehler++;
echo '<br><br>'.$zaehler.'<br><br>';
if ($zaehler==1){
$colour='rot';
} elseif ($zaehler==2){
$colour='green';
} else {
$colour='blue';
$zaehler=0;
}
if ($file !=='files' && $file !=='private' && $file !=='mail' && $file !=='sommer2008'){
echo '<p><a class="'.$colour.'" href="'.$file.'"> </a>';
echo '<a href="'.$file.'">'.$file.'</a>';
}
}
closedir($handle);
?>
</table>
</body>
</html>
|
|
|
|
|
|
#5 |
|
Veteran
![]() Registriert seit: 07.11.2003
Alter: 51
Beiträge: 393
|
ah, ich bin so dämlich, das wo er keine farbe zuordnet sind die ausnahmen in der "if ($file.." schleife, mannomann, sorry und thx für die tipps
so funkts natürlich Code:
<head>
<link rel="stylesheet" type="text/css" href="css.css">
<title>
Index of /
</title>
</head>
<body>
<?php
$zaehler=0;
// open the current directory by opendir
$handle=opendir(".");
while (($file = readdir($handle))!==false) {
if ($file !=='files' && $file !=='private' && $file !=='mail' && $file !=='sommer2008'){
$zaehler++;
#echo '<br><br>'.$zaehler.'<br><br>';
if ($zaehler==1){
$colour='rot';
} elseif ($zaehler==2){
$colour='green';
} else {
$colour='blue';
$zaehler=0;
}
echo '<p><a class="'.$colour.'" href="'.$file.'"> </a>';
echo '<a href="'.$file.'">'.$file.'</a>';
}
}
closedir($handle);
?>
</table>
</body>
|
|
|
|
![]() |
| Aktive Benutzer in diesem Thema: 1 (Registrierte Benutzer: 0, Gäste: 1) | |
|
|