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

count only commas outside parenteses
I have a sql table containing
id - query - query name
the first page contains a drop down men

IF STATEMENT HELP
Hi
i have created a calendar from a table:

Code: Calendar: October 2009
<table w

str_replace help
Hey there,

I'm a PHP newb, I'm having troubles with the str_replace function. I want to clean

Need help adding a timestamp to my filename/variable
Hello,

I'm kind of stupid when it comes to php and I need a tiny bit of help. I've got a f

Quick Syntax Question
Hi folks,

I'm getting the following error: "unexpected T_LNUMBER". I'm trying to b

Posting Serialized Data Not Working
I am trying to send an object from one PHP file to another using POST. I serialize the object and th

HOW to get the bind variables list.
I've the following problem : I've some SQL queries stored in my DB as VARCHAR2 values.
I need t

Undefined variable when using $_SERVER['PHP_SELF']
Hi guyz, please suggest me something...
On first.php I have one input field NAME, and on posting

Form submissing with PHP and JQuery/Ajax
I have searched everywhere, but cannot find a solution for this... I have worked all day trying to g

simple php table loop
Hi all,

I've the following code

<?php // Create category options

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