Ich finde keine Lösung, die Downloads nach dem größten Wert automatisch sortieren zu lassen.
Im Moment gibt es die Tabellen so aus, wie sie in Reihenfolge in der cfg.php stehen.
Hier der Script:
[PHP]<?php
if($_SESSION[‚logged_in‘]){
$order = $_GET['order']?$_GET['order']:'titel';
$fol = $_GET['fol']?$_GET['fol']:'DESC';
if($_GET['order']=="datum"){
$fol = $_GET['fol'];
$order = "datum ".$fol." , zeit";
}
$first = '#FFFFFF';
$second = '#f0f8ff';
$color = $first;
?>
Download Statistiken
<?phpforeach($tabelle as $val){
?>
<td width="80" bgcolor="<?php echo $color;?>"><?php echo $val; ?></td>
<?php
$color = $color==$first?$second:$first;
}
?>
<?php
$first = '#FFFFFF';
$second = '#f0f8ff';
$color = $first;
$downloads = 0;
foreach($tabelle as $val){
$query = mysql_query("SELECT * FROM `".$val."`");
while($Row = mysql_fetch_assoc($query)) {
$downloads += $Row['clicks'];
}
?>
<td bgcolor="<?php echo $color;?>"><?php echo $downloads;?></td>
<?php
$color = $color==$first?$second:$first;
$downloads = 0;
}
?>
Artist: |
Downloads: |
$first = '#FFFFFF';
$second = '#f0f8ff';
$color = $first;
foreach( $tabelle as $val ) {
$sql = mysql_query("SELECT * FROM `".$val."`") or die(mysql_error());
while( $row2 = mysql_fetch_assoc($sql) ) {
$sql3 = mysql_query("SELECT * FROM `statistiken` WHERE `titel`='".mysql_real_escape_string($row2['titel'])."' ");
if(mysql_num_rows($sql3)<1){
if( $row2['filesize'] < 1 ) {
$filesize=0;
}else {
$filesize=$row2['filesize'];
}
$enter = mysql_query("INSERT INTO `statistiken` ( `id` , `titel` , `datum` , `zeit` , `clicks` , `filesize` , `last` , `tid` ) VALUES ( NULL , '".mysql_real_escape_string($row2['titel'])."' , '".$row2['datum']."' , '".$row2['zeit']."' , '".$row2['clicks']."' , '".$filesize."' , '".$row2['last']."' , '".$row2['id']."' ) ") or die("Error: ".mysql_error());
}
}
}
$sql2 = mysql_query("SELECT * FROM `statistiken` ORDER BY ".mysql_real_escape_string($order)." ".mysql_real_escape_string($fol));
while( $row = mysql_fetch_assoc($sql2) ){
$filesize = $row['filesize'];
$filesize /= 1000000;
$filesize = explode(".",$filesize);
$filefront = $filesize[0];
$fileback = substr($filesize[1],0,2);
$last = $row['last'];
$last = explode(" ",$last);
$last[0] = explode("-",$last[0]);
$lastfront = $last[0][2].".".$last[0][1].".".$last[0][0];
$lastback = $last[1];
echo "
<tr align=\"center\" bgcolor=\"".$color."\">
<td >".$row['tid']."</td>
<td align=\"left\" style=\"color:#000000;\">".$row['titel']."</td>
<td>".$row['datum']." ".$row['zeit']."</td>
<td>".$row['clicks']."</td>
<td>".$filefront.".".$fileback." MB</td>
<td>".$lastfront." ".$lastback."</td>
</tr>
";
$downloads += $row['clicks'];
$color = $color==$first?$second:$first;
}
?>
}
?>
[/PHP]Es geht im speziellen um diesen Abschnitt:
[PHP]
<?phpforeach($tabelle as $val){
?>
<td width="80" bgcolor="<?php echo $color;?>"><?php echo $val; ?></td>
<?php
$color = $color==$first?$second:$first;
}
?>
<?php
$first = '#FFFFFF';
$second = '#f0f8ff';
$color = $first;
$downloads = 0;
foreach($tabelle as $val){
$query = mysql_query("SELECT * FROM `".$val."`");
while($Row = mysql_fetch_assoc($query)) {
$downloads += $Row['clicks'];
}
?>
<td bgcolor="<?php echo $color;?>"><?php echo $downloads;?></td>
<?php
$color = $color==$first?$second:$first;
$downloads = 0;
}
?>
Artist: |
Downloads: |