NamePros
Welcome, Guest! Ready to make a name for yourself in the domain business? We welcome both the hobbyist and professional domainer to join the discussion as part of the NamePros community.

Click here to create your profile to start earning reputation for posting, and trader ratings for buying & selling in our free e-marketplace. Build your trader rating with each successful sale. Our system has tracked over 100,000 sales and counting!
FAQ & TOS Register Search Today's Posts Mark Forums Read

Go Back   NamePros.com > Website Development Discussion Forums > Programming
Reload this Page Oh my God I am confused

Programming PHP, Perl, Ruby on Rails, AJAX, HTML, XHTML, CSS, JavaScript, MySQL and any other coding topics.

Advanced Search


Closed Thread
 
LinkBack Thread Tools
Old 11-03-2005, 06:48 PM THREAD STARTER               #1 (permalink)
Senior Member
 
Ringr's Avatar
Join Date: Jul 2004
Posts: 1,383
Ringr is a splendid one to beholdRingr is a splendid one to beholdRingr is a splendid one to beholdRingr is a splendid one to beholdRingr is a splendid one to beholdRingr is a splendid one to beholdRingr is a splendid one to beholdRingr is a splendid one to behold
 



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); 
?>
Since I basically have no idea how it could be used with a five-columned table, some guy told me to use this:
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>";
Well, I have no idea on earth how the hell the code he gave me is to be used with the first script is supposed to go. I have tried in every single way, shape, and form that I know of to try and get the two to work as one. But nope, I get parse error after parse error after parse error.

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
Ringr is offline  
Old 11-04-2005, 01:05 PM   #2 (permalink)
You are here: X
 
mr-x's Avatar
Join Date: Oct 2003
Location: US
Posts: 483
mr-x is a glorious beacon of lightmr-x is a glorious beacon of lightmr-x is a glorious beacon of lightmr-x is a glorious beacon of lightmr-x is a glorious beacon of light
 



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.
mr-x is offline  
Old 11-04-2005, 04:41 PM THREAD STARTER               #3 (permalink)
Senior Member
 
Ringr's Avatar
Join Date: Jul 2004
Posts: 1,383
Ringr is a splendid one to beholdRingr is a splendid one to beholdRingr is a splendid one to beholdRingr is a splendid one to beholdRingr is a splendid one to beholdRingr is a splendid one to beholdRingr is a splendid one to beholdRingr is a splendid one to behold
 



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); 
?>
This however is the HTML it is outputing:
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>
Any ideas why it is making the code: <a href="aim:BuddyIcon?src=http://www.iming.org/imsite/gallery/icons/.">
????: 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.
Ringr is offline  
Old 11-12-2005, 08:47 AM   #4 (permalink)
You are here: X
 
mr-x's Avatar
Join Date: Oct 2003
Location: US
Posts: 483
mr-x is a glorious beacon of lightmr-x is a glorious beacon of lightmr-x is a glorious beacon of lightmr-x is a glorious beacon of lightmr-x is a glorious beacon of light
 



"." & ".." 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;
}
with echo '<td colspan="5"'><td>';
????: 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.
mr-x is offline  
Closed Thread


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

Liquid Web Smart Servers  
All times are GMT -7. The time now is 12:51 AM.

Managed Web Hosting by Liquid Web
Domain name forum recommended by Domaining.com Powered by: vBulletin® Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.
Search Engine Friendly URLs by vBSEO 3.6.0 Ad Management plugin by RedTyger