Jump to content
Updating IPB tonight Read more... ×

Archived

This topic is now archived and is closed to further replies.

DieSucker

Table making help

Recommended Posts

OK so i have written this script
[code]$d = dir("./");

while(false !== ($e = $d->read()))
if ($e != "." && $e != ".." && $e !="index.php") {
   
  $insertFILE = "insert into information2(map_name, map_size) values ('" . $e . "', '" . formatbytes(filesize($e)) . "')";
  $resultFILE = mysql_query($insertFILE);
    echo $e . "\n" . formatbytes(filesize($e)) . "\n" . '<br/>';
  }

?>[/code]
so then the database will look like
[code]
      CTF-BT-YouAreLOL.zip 389 kB
      CTF-BT-YouAreOnCoke.zip 5.38 MB
      CTF-BT-Zwielicht-2.zip 546 kB
      CTF-BT-Zyron.zip 758 kB

[/code]
I anna read the list into a table, but the table needs to go 3 entries across, doesn't mater how far it goes down, each cell it include the file name and size ie CTF-BT-YouAreLOL.zip(389 kB)
I just dont know how to get it to 3 across then end the tr
any help?

Share this post


Link to post
Share on other sites
Try this...

[code]
<?php

$d = dir("./");
echo "<table>\n <tr>";
counter = 0;

while(false !== ($e = $d->read()))
if ($e != "." && $e != ".." && $e !="index.php")
{
    $insertFILE = "insert into information2(map_name, map_size) values ('" . $e . "', '" . formatbytes(filesize($e)) . "')";
    $resultFILE = mysql_query($insertFILE);
    counter ++;
    echo $e . "  <td>" . formatbytes(filesize($e)) . "</td>\n";

    //place a new line in the table after 3 entries
    if (counter == 3)
    {
          counter = 0;
          echo " </tr>\n <tr>\n";
    }
}

echo " </tr>\n</table>

?>[/code]

The above will get you started but you will need to do some fine tweeking for like if the last row only has 1 item etc.. in it.  Good luck

Share this post


Link to post
Share on other sites

×

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.