I have two loops that i want to combine together or use them both together.
The while loop grabs the info i want.
// Open a known directory, and proceed to read its contents
$fullpath = 'galleries/';
$dir = 'holidays/elf-sex/'; // pull from mysql
$newpath = $fullpath.$dir;
if ($handle = opendir($newpath)) {
$i = 0;
while (false !== ($file = readdir($handle))) {
if ($file != "." && $file != ".." && $file != "thumbnails") {
$i++;
}
}
echo "There are " . $i . " files in this directory";
closedir($handle);
}
if ($dh = opendir($newpath)) {
while (($file = readdir($dh)) !== false) {
// Block files from being displayed
if ($file != "." && $file != ".." && $file != "thumbnails") {
// Display
echo 'This is the file: '.$file.' and this is the location of it: '.$dir.'<BR>';
}// IFELSE FILE BLOCKER
}// WHILE LOOP
closedir($dh);
} // IFELSE OPENDIR
And the for loop puts everything thing in a table that is so many collums wide.
This loop i used with a mysql queury
//set the number of columns
$columns = 2;
//we add this line because we need to know the number of rows
//changed this to a for loop so we can use the number of rows
for($i = 0; $i < $num_rows; $i++) {
$myrow = mysql_fetch_array($result);
if($i % $columns == 0) {
//if there is no remainder, we want to start a new row
echo "<TR>\n";
}
echo 'this is where everything goes.';
if(($i % $columns) == ($columns - 1) || ($i + 1) == $num_rows) {
//if there is a remainder of 1, end the row
//or if there is nothing left in our result set, end the row
echo "</TR>\n";
}
}