| | |||||
| ||||||||
| Programming PHP, Perl, Ruby on Rails, AJAX, HTML, XHTML, CSS, JavaScript, MySQL and any other coding topics. |
![]() |
| | LinkBack | Thread Tools |
| | THREAD STARTER #1 (permalink) |
| Senior Member Join Date: Jul 2004
Posts: 1,383
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() | Oh my God I am confused I swear, my head is going to split, I am SO confused right now I'm about to yank my effing hair out. Okay, so I have this to work with (and keep in mind I know just about jack for PHP and I'm not even halfway finished with a book on it). ????: NamePros.com http://www.namepros.com/programming/137375-oh-my-god-i-am-confused.html Code: <?
//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.iming.org/imsite/gallery/icons/$file><img src=http://www.iming.org/imsite/gallery/icons/$file border=0></a>";
} else {
echo "<a href=aim:BuddyIcon?src=http://www.iming.org/imsite/gallery/icons/$file><img src=http://www.iming.org/imsite/gallery/icons/$file border=0></a>";
}}}
//close directory
closedir($hook);
?> Code: 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>"; Does anyone know how I am supposed to make the second script go with the first one? Will give 75 NP$ to anyone that can help me sort this out, sorry for sound like a bumbling idiot. Thanks in advance, Andy |
| |
| | #2 (permalink) |
| You are here: X Join Date: Oct 2003 Location: US
Posts: 483
![]() ![]() ![]() ![]() ![]() | Just replace the while loop in your script with the one provided. Add the print/echo statments for the table and then change ( stuff to display ) to (($file = readdir($hook)) !== false) Then at the end of the loop add the print / echo to close the table. |
| |
| | THREAD STARTER #3 (permalink) |
| Senior Member Join Date: Jul 2004
Posts: 1,383
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() | It's working but it's got a glitch in it I did what you recommended Tres, and it's working somewhat now - but it's making faulty code right now. Here's the coding: Code: <?
//get directory handle
$hook = opendir("icons");
//start the table
echo "<table>\n";
echo "<tr>\n";
$counter = 0;
//read directory and echo list
while (($file = readdir($hook)) !== false)
{
// start a new row
if ($counter == 5)
{
echo "</tr>\n<tr>\n";
}
echo "<td>\n<a href=\"aim:BuddyIcon?src=http://www.iming.org/imsite/gallery/icons/$file\">\n<img src=\"http://www.iming.org/imsite/gallery/icons/$file\" border=0></a></td>\n";
// 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>\n";
++$counter;
}
// close row and table
echo "</tr>\n";
echo "</table>\n";
}
//set up full path
$path = $location."/".$file;
//check for directory
if (is_dir($path))
//close directory
closedir($hook);
?> Code: <table> <tr> <td> <a href="aim:BuddyIcon?src=http://www.iming.org/imsite/gallery/icons/."> <img src="http://www.iming.org/imsite/gallery/icons/." border=0></a></td> <td></td> <td></td> <td></td> <td></td> </tr> </table> </tr> <tr> <td> <a href="aim:BuddyIcon?src=http://www.iming.org/imsite/gallery/icons/.."> <img src="http://www.iming.org/imsite/gallery/icons/.." border=0></a></td> <td></td> <td></td> <td></td> <td></td> </tr> </table> </tr> <tr> <td> <a href="aim:BuddyIcon?src=http://www.iming.org/imsite/gallery/icons/nfsupport.gif"> <img src="http://www.iming.org/imsite/gallery/icons/nfsupport.gif" border=0></a></td> <td></td> <td></td> <td></td> <td></td> </tr> </table> </tr> <tr> <td> <a href="aim:BuddyIcon?src=http://www.iming.org/imsite/gallery/icons/nfsupport3.gif"> <img src="http://www.iming.org/imsite/gallery/icons/nfsupport3.gif" border=0></a></td> <td></td> <td></td> <td></td> <td></td> </tr> </table> ????: NamePros.com http://www.namepros.com/showthread.php?t=137375 <img src="http://www.iming.org/imsite/gallery/icons/." border=0></a></td> as an image when it shouldn't be at all, and why it's not making any of the Tables proper (like: </tr> </table> </tr>)? Thanks, Andy
Last edited by AndyM3; 11-04-2005 at 05:01 PM.
|
| |
| | #4 (permalink) |
| You are here: X Join Date: Oct 2003 Location: US
Posts: 483
![]() ![]() ![]() ![]() ![]() | "." & ".." are directories. "." is the current dir and ".." is the parent. If you will not have any sub-directories, you can us is_file(), otherwise you should check for the "." or ".." shortcuts. Add If ($file !== "." and $file !== "..") or if(is_file($file) after while statement. You should replace Code: while ($counter < 5)
{
echo "<td></td>\n";
++$counter;
} ????: NamePros.com http://www.namepros.com/showthread.php?t=137375 for the correct HTML, you need to add a "<table>" at the top of your loop or move the closing "</table>" to after the loop. |
| |
![]() |
| Currently Active Users Viewing This Thread: 1 (0 members and 1 guests) | |
| Thread Tools | |
| |
Similar Threads | ||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| I am still to be confused regarding... | dgridley | The Break Room | 6 | 10-26-2005 10:26 PM |