displaying unknown amount of results


Posted on 16th Feb 2014 07:03 pm by admin

I am reading a directory and getting a list of folders in the directory, I want to display the folders in a table which is 6 columns of results across by how ever may rows, here is the code I am using now which gets the folders and displays the table correctly, but it is currently only displaying the first result in an infinite loop.

Code: <?php
$d='action'; #define which dir you want to read
$dir = opendir($d); #open directory
while ($f = readdir($dir)) {
/* echo '<a href="'.$f.'/index.htm" target="_parent"><img src="'.$d.'/'.$f.'/folder.jpg" border="0"></a>
'; */
if ($f!="." && $f!=".." && (!is_file($f))) {
echo '<table cellspacing="5" cellpadding="4" align="center">';
$tdcount = 1;
while ($f) {
if($tdcount % 6 == 1) echo "<tr>";
echo '<td><font face="arial" size="1">';
echo '<a href="'.$f.'/index.htm" target="_parent"><img src="'.$d.'/'.$f.'/folder.jpg" border="0"></a></td>';
if($tdcount % 6 == 0) echo "</tr>";
$tdcount++;
}
echo "</table>";
}
}
?>How do i make it display each result instead of only the first result.

No comments posted yet

Your Answer:

Login to answer
68 Like 38 Dislike
Previous forums Next forums
Other forums

Login logout link help
Hi all,

Im new to php and Im having trouble creating a login/logout link for my page that dis

Filtering for a phrase using pregmatch
Here is my code which looks for addresses which start with ' src=" '

Code: [Select]preg_

Help Ordering Arrays
Hi, I have 3 arrays as shown below.

Code: $users = $this->get_latest_users();
$flir

simple ping code
been searchin the site/web and found code thats simple but doesnt work.

I have a personal we

Random date selection
i want to select random date with time(hour+minutes+sec) where date is specified(10/22/2009) and tim

Certain files upload, while others do not
I want to read the data from an uploaded file. Not sure why, but it only uploads for certain files.

Getting number of affected rows in SQLPLUS..
Hi everyone,
I have a shell script where i am invoking sqlplus, running a query and saving t

session_destroy();
new to php
I have a simple login and am trying to write a logout.
I set a $_SESSION var to 1 i

PHP4 to PHP5 Conversion
Hi Everyone,

I am working on a site that is built up on PHP4 and each page is being started f

Fatal error: Call to a member function fetchrow() on a non-object in C:xamppht
okay i have this query and everytime i add `item_id`=? to it... it gives me the error in the title..

Sign up to write
Sign up now if you have flare of writing..
Login   |   Register
Follow Us
Indyaspeak @ Facebook Indyaspeak @ Twitter Indyaspeak @ Pinterest RSS



Play Free Quiz and Win Cash