Please help! I can't figure this out.

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
drik
Forum Newbie
Posts: 1
Joined: Thu Nov 03, 2005 7:12 pm

Please help! I can't figure this out.

Post by drik »

Hey guys,

This is a script for an AIM buddy icon site I'm making.

Code: Select all

<?  
//get directory handle  
$hook = opendir("icons");  
//read directory and echo list  
while (($file = readdir($hook)) !== false)  
{  
if ($file != "." && $file != "..")  
{  
//set up full path  
$path = $location."/".$file;  
//check for directory  
if (is_dir($path))  

{  
echo "<a href=aim:BuddyIcon?src=http://www.mysite.org/imsite/gallery/icons/$file><img src=http://www.mysite.org/imsite/gallery/icons/$file border=0></a>";  
} else {  
echo "<a href=aim:BuddyIcon?src=http://www.mysite.org/imsite/gallery/icons/$file><img src=http://www.mysite.org/imsite/gallery/icons/$file border=0></a>";  
}}}  
//close directory  
closedir($hook);  
?>
I honestly have no idea how I can make it so that it displays each buddy icon in its own table cells with 5 cells going across.

I'm sorry but I'm just absolutely stumped, can anyone help me?

Thanks,
drik
timvw
DevNet Master
Posts: 4897
Joined: Mon Jan 19, 2004 11:11 pm
Location: Leuven, Belgium

Post by timvw »

You mean that you want to create a table, with 5 columns on each row?

Code: Select all

echo "<table>";
echo "<tr>";

$counter = 0;

while ( stuff to display)
{
         // start a new row
         if ($counter == 5)
         {
               echo "</tr><tr>";
         }

         echo "<td> stuff ... </td>";

         // add 1 to counter, or go back to 1
         $counter = ($counter + 1) % 5;
}

// need to fill up last row with empty columns
while ($counter < 5)
{
   echo "<td></td>";
   ++$counter;
}

// close row and table
echo "</tr>";
echo "</table>";
User avatar
Luke
The Ninja Space Mod
Posts: 6424
Joined: Fri Aug 05, 2005 1:53 pm
Location: Paradise, CA

Post by Luke »

sorry to clutter the thread, but anybody ever give you money like it says to in your sig, tim?
timvw
DevNet Master
Posts: 4897
Joined: Mon Jan 19, 2004 11:11 pm
Location: Leuven, Belgium

Post by timvw »

I don't remember how that ended up in my sig anymore..
I've worked all those hours overhere and only earned $25 :p Compare that to wages mentionned in the Enterprise threads :p If i really did it for the money i would probably have to change my strategy ;)
User avatar
Luke
The Ninja Space Mod
Posts: 6424
Joined: Fri Aug 05, 2005 1:53 pm
Location: Paradise, CA

Post by Luke »

timvw wrote:I don't remember how that ended up in my sig anymore..
I've worked all those hours overhere and only earned $25 :p Compare that to wages mentionned in the Enterprise threads :p If i really did it for the money i would probably have to change my strategy ;)
well $25 aint too shabby. :D
Post Reply