Jump to content


Photo

Table making help


  • Please log in to reply
2 replies to this topic

#1 DieSucker

DieSucker
  • Members
  • PipPip
  • Member
  • 22 posts

Posted 17 July 2006 - 05:10 AM

OK so i have written this script
$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/>';
   }

?>
so then the database will look like
      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 

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?

#2 cunoodle2

cunoodle2
  • Members
  • PipPipPip
  • Advanced Member
  • 602 posts

Posted 17 July 2006 - 05:57 AM

Try this...

<?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>

?>

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

If the code was working and now it's not, something changed. Did you change any code?

yeah, just a little bit, I am trying to start from beginning and trace my steps to see what i did wrong unless you see it.


#3 DieSucker

DieSucker
  • Members
  • PipPip
  • Member
  • 22 posts

Posted 17 July 2006 - 06:06 AM

you da man cunoodle2 , thanks so much




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users