Go Back   CodingForums.com > :: Server side development > PHP

Before you post, read our: Rules & Posting Guidelines

Reply
 
Thread Tools Rate Thread
Enjoy an ad free experience by logging in. Not a member yet? Register.
Old 03-12-2007, 06:14 PM   PM User | #1
the-dream
Regular Coder

 
the-dream's Avatar
 
Join Date: Mar 2007
Location: Northamptonshire, UK
Posts: 477
Thanks: 8
Thanked 4 Times in 4 Posts
the-dream can only hope to improve
Formatting A ( While )???

I have some PHP:

PHP Code:
<?php
$dir 
"/";

// Open a known directory, and proceed to read its contents
if (is_dir($dir)) {
   if (
$dh opendir($dir)) {
       while ((
$file readdir($dh)) !== false) {
           echo 
$file;
           echo 
"<br />";
       }
       
closedir($dh);
   }
}
?>
It checks all the files in a directory then list each file on a new line.
Is there eny way of formatting each line for example the first line bg is grey the second is white the third is then grey and so on. How is this done???
__________________
Branchr Advertising Network
the-dream is offline   Reply With Quote
Old 03-12-2007, 07:23 PM   PM User | #2
raamdev
New to the CF scene

 
Join Date: Mar 2007
Posts: 1
Thanks: 0
Thanked 0 Times in 0 Posts
raamdev is an unknown quantity at this point
PHP Code:
<?php
$dir 
"/";

// Open a known directory, and proceed to read its contents
if (is_dir($dir)) {
   if (
$dh opendir($dir)) {
       
$i 0;
       while ((
$file readdir($dh)) !== false) {
           if (
$i == 0) { 
                      
$color "#999999";
                      
$i 1;
           }
           else {
                      
$color "#CCCCCC";
                      
$i 0;
           }
           echo 
'<div style="background-color:' $color '">' $file '</div>';
           
// echo "<br />";
       
}
       
closedir($dh);
   }
}
?>
raamdev is offline   Reply With Quote
Old 03-12-2007, 07:48 PM   PM User | #3
the-dream
Regular Coder

 
the-dream's Avatar
 
Join Date: Mar 2007
Location: Northamptonshire, UK
Posts: 477
Thanks: 8
Thanked 4 Times in 4 Posts
the-dream can only hope to improve
Thats Great!
T H A N K S!
__________________
Branchr Advertising Network
the-dream is offline   Reply With Quote
Old 03-12-2007, 08:06 PM   PM User | #4
the-dream
Regular Coder

 
the-dream's Avatar
 
Join Date: Mar 2007
Location: Northamptonshire, UK
Posts: 477
Thanks: 8
Thanked 4 Times in 4 Posts
the-dream can only hope to improve
i have my code:

PHP Code:
<?php
$dir 
"/";

// Open a known directory, and proceed to read its contents
if (is_dir($dir)) {
   if (
$dh opendir($dir)) {
       
$i 0;
       while ((
$file readdir($dh)) !== false) {
           if (
$i == 0) { 
                      
$color "#999999";
                      
$i 1;
           }
           else {
                      
$color "#CCCCCC";
                      
$i 0;
           }
           echo 
'<div class="boxes"><div class="boxes" style="background-color:' $color '">' $file '</div></div>';
       }
       
closedir($dh);
   }
}
?>

and then i want a check box for each one so you could delete the file.
How???

Ty!
__________________
Branchr Advertising Network
the-dream is offline   Reply With Quote
Old 03-12-2007, 08:17 PM   PM User | #5
StupidRalph
Senior Coder

 
Join Date: Mar 2003
Location: Atlanta
Posts: 1,037
Thanks: 14
Thanked 30 Times in 28 Posts
StupidRalph is on a distinguished road
You'll have to have wrap your code with a form and dynamically write out a checkbox with each file:

PHP Code:
echo '<div class="boxes"><div class="boxes" style="background-color:' $color '"><input name="del_file" type="checkbox" value="' .$file .'" />' $file '</div></div>'
This will make an array with the check box values...once you submit the form search to see which files have been checked and use the unlink() to delete them.
__________________
Most of my questions/posts are fairly straightforward and simple. I post long verbose messages in an attempt to be thorough.

Last edited by StupidRalph; 03-12-2007 at 08:33 PM.. Reason: forgot to add value
StupidRalph is offline   Reply With Quote
Old 03-12-2007, 08:30 PM   PM User | #6
the-dream
Regular Coder

 
the-dream's Avatar
 
Join Date: Mar 2007
Location: Northamptonshire, UK
Posts: 477
Thanks: 8
Thanked 4 Times in 4 Posts
the-dream can only hope to improve
I Don't Understand!

Sorry ive been doing PHP for bout a year and a half but dident really learn anything!
__________________
Branchr Advertising Network
the-dream is offline   Reply With Quote
Old 03-12-2007, 08:44 PM   PM User | #7
StupidRalph
Senior Coder

 
Join Date: Mar 2003
Location: Atlanta
Posts: 1,037
Thanks: 14
Thanked 30 Times in 28 Posts
StupidRalph is on a distinguished road
I've replied in your other thread here...

http://www.codingforums.com/showthre...d=1#post544478
__________________
Most of my questions/posts are fairly straightforward and simple. I post long verbose messages in an attempt to be thorough.
StupidRalph is offline   Reply With Quote
Reply

Bookmarks

Jump To Top of Thread


Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT +1. The time now is 04:57 PM.


Advertisement
Log in to turn off these ads.