Jump to content

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?
Link to comment
https://forums.phpfreaks.com/topic/14815-table-making-help/
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
Link to comment
https://forums.phpfreaks.com/topic/14815-table-making-help/#findComment-59190
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

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.