PHP beginner |
|
ik had dit scriptje om de filesize te berekenen en het werkte:
<?
$iFileSize = filesize('naam van de file hier');
if($iFileSize >= 1048567)
{
$iFileSizeMB = $iFileSize / 1048567;
$iFileSizeMBafgerond = round($iFileSizeMB, 2);
echo $iFileSizeMBafgerond." Mb";
}
elseif($iFileSize >= 1024 && $iFileSize < 1048567)
{
$iFileSizeKB = $iFileSize / 1024;
$iFileSizeKBafgerond = round($iFileSizeKB, 2);
echo $iFileSizeKBafgerond." Kb";
}
else
$iFileSizeafgerond = round($iFileSize, 2);
echo $iFileSizeafgerond. "b";
?>
<? $iFileSize = filesize('naam van de file hier'); if($iFileSize >= 1048567) { $iFileSizeMB = $iFileSize / 1048567; $iFileSizeMBafgerond = round($iFileSizeMB, 2); echo $iFileSizeMBafgerond." Mb"; } elseif($iFileSize >= 1024 && $iFileSize < 1048567) { $iFileSizeKB = $iFileSize / 1024; $iFileSizeKBafgerond = round($iFileSizeKB, 2); echo $iFileSizeKBafgerond." Kb"; } else $iFileSizeafgerond = round($iFileSize, 2); echo $iFileSizeafgerond. "b"; ?>
maar als ik het nu in m'n 'echte' script zet werkt het niet(ik krijg gee n errors maar het script wordt gewoon in tekst weergeven en niet uitgevoerd):
<?php
include("../../dbconnect.php");
$sQuery = mysql_query("SELECT * FROM htmldownloads ORDER BY naam ASC") or die (Mysql_Error());
$list = '<table width="503" border="0" cellspacing="0" cellpadding="0" class="kader">';
$i = "kolom1";
while($r = mysql_fetch_array($sQuery)) {
$list .= '<tr class="'. $i .'">
<td width="153"><a href="'. $r['link'] . '">'. $r['naam'] . '</a></td>
<td width="96" class"kolom4">'. $r['visits'] . '</td>
<td width="115">
$iFileSize = filesize("'. $r['filelink'] . '");
if($iFileSize >= 1048567)
{
$iFileSizeMB = $iFileSize / 1048567;
$iFileSizeMBafgerond = round($iFileSizeMB, 2);
echo $iFileSizeMBafgerond." Mb";
}
elseif($iFileSize >= 1024 && $iFileSize < 1048567)
{
$iFileSizeKB = $iFileSize / 1024;
$iFileSizeKBafgerond = round($iFileSizeKB, 2);
echo $iFileSizeKBafgerond." Kb";
}
else
$iFileSizeafgerond = round($iFileSize, 2);
echo $iFileSizeafgerond. "b";
?></td>
<td width="137">'. $r['type'] . '</td>
</tr>';
if($i == "kolom1") { $i = "kolom2"; } else { $i = "kolom1"; }
}
$list .= '</table>';
echo $list;
?>
<?php include("../../dbconnect.php"); $list = '<table width="503" border="0" cellspacing="0" cellpadding="0" class="kader">'; $i = "kolom1"; $list .= '<tr class="'. $i .'"> <td width="153"><a href="'. $r['link'] . '">'. $r['naam'] . '</a></td> <td width="96" class"kolom4">'. $r['visits'] . '</td> <td width="115"> $iFileSize = filesize("'. $r['filelink'] . '"); if($iFileSize >= 1048567) { $iFileSizeMB = $iFileSize / 1048567; $iFileSizeMBafgerond = round($iFileSizeMB, 2); echo $iFileSizeMBafgerond." Mb"; } elseif($iFileSize >= 1024 && $iFileSize < 1048567) { $iFileSizeKB = $iFileSize / 1024; $iFileSizeKBafgerond = round($iFileSizeKB, 2); echo $iFileSizeKBafgerond." Kb"; } else $iFileSizeafgerond = round($iFileSize, 2); echo $iFileSizeafgerond. "b"; ?></td> <td width="137">'. $r['type'] . '</td> </tr>'; if($i == "kolom1") { $i = "kolom2"; } else { $i = "kolom1"; } } $list .= '</table>'; ?>
|