Tycoon Talk
Become a Big fish!
The number 1 forum for online business!
Post topics, ask questions, share your knowledge.
Tycoon Talk is part of Freelancer.com - find skilled workers online at a fraction of the cost.

PHP Forum


You are currently viewing our PHP Forum as a guest. Please register to participate.
Login



Freelance Jobs

Reply
Not printing file names in dir if in db - HELP PLEASE!
Old 04-23-2006, 02:18 PM Not printing file names in dir if in db - HELP PLEASE!
mad_willsy's Avatar
Super Spam Talker

Latest Blog Post:
R&R Catering Hire Testimonial
Posts: 805
Name: Will Craig
Location: Cheltenham, Gloucestershire, UK
Trades: 0
I have a script where i upload files and then they are printed in a dropdown menu for me to add them to db; along with other information.

The code to print dropdown menu is as follows:

PHP Code:
<?php
                
                $dir 
opendir('../images/upload');
                    while(
false !== ($file readdir($dir))){
                        if(
$file != "." && $file != ".." && $file != "Thumbs.db"){
                            echo 
'<option value="'.$file.'">'.$file.'</option>';
                        }
                    }
                    
closedir($dir);
                    
                    
                
?>
Any chance of an if statement that will check if $file is in field (location), in table (games), in any record before printing
PHP Code:
<option value="'.$file.'">'.$file.'</option
?
__________________
Wont :P

Please login or register to view this content. Registration is FREE
mad_willsy is offline
Reply With Quote
View Public Profile Visit mad_willsy's homepage!
 
 
Register now for full access!
Old 04-23-2006, 02:19 PM Re: Not printing file names in dir if in db - HELP PLEASE!
mad_willsy's Avatar
Super Spam Talker

Latest Blog Post:
R&R Catering Hire Testimonial
Posts: 805
Name: Will Craig
Location: Cheltenham, Gloucestershire, UK
Trades: 0
Also if possoble, if it passes this test, it produces an array and sorts it, then prints it?
__________________
Wont :P

Please login or register to view this content. Registration is FREE
mad_willsy is offline
Reply With Quote
View Public Profile Visit mad_willsy's homepage!
 
Old 04-24-2006, 04:37 AM Re: Not printing file names in dir if in db - HELP PLEASE!
0beron's Avatar
Defies a Status

Posts: 1,832
Location: Somewhere else entirely
Trades: 0
PHP Code:
<?php
$files 
= Array();
$dir opendir('images');
while(
false !== ($file readdir($dir))){
  if(
$file != "." && $file != ".." && $file != "Thumbs.db"){
    
$files[] = $file;
  }
}
closedir($dir);

$files=array_flip($files);

//Connect to your database here unless you have already

$result mysql_query("SELECT location FROM games");

while(
$row mysql_fetch_array($result)) {
  unset(
$files[$row['location']]);
}

$filesarray_flip($files);

sort($file);
foreach(
$files as $file) {
  echo 
'<option value="'.$file.'">'.$file.'</option>';
}


?>
Try this ^
__________________
UPDATE 0beron SET talkupation = talkupation + lots WHERE post = 'helpful';

Please login or register to view this content. Registration is FREE
(aka MSN handwriting for forums)
0beron is offline
Reply With Quote
View Public Profile Visit 0beron's homepage!
 
Old 04-25-2006, 01:19 PM Re: Not printing file names in dir if in db - HELP PLEASE!
mad_willsy's Avatar
Super Spam Talker

Latest Blog Post:
R&R Catering Hire Testimonial
Posts: 805
Name: Will Craig
Location: Cheltenham, Gloucestershire, UK
Trades: 0
You sorted $file rather than $files, but i sorted that and costomised it and it works now.

THANKS
__________________
Wont :P

Please login or register to view this content. Registration is FREE
mad_willsy is offline
Reply With Quote
View Public Profile Visit mad_willsy's homepage!
 
Old 04-25-2006, 03:37 PM Re: Not printing file names in dir if in db - HELP PLEASE!
0beron's Avatar
Defies a Status

Posts: 1,832
Location: Somewhere else entirely
Trades: 0
Ooops, well spotted.
__________________
UPDATE 0beron SET talkupation = talkupation + lots WHERE post = 'helpful';

Please login or register to view this content. Registration is FREE
(aka MSN handwriting for forums)
0beron is offline
Reply With Quote
View Public Profile Visit 0beron's homepage!
 
Reply     « Reply to Not printing file names in dir if in db - HELP PLEASE!
 

Thread Tools Search this Thread
Search this Thread:

Advanced Search

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
Trackbacks are Off
Pingbacks are Off
Refbacks are Off





   
RSS Feed  Feeds: RSS   JS   XML
RSS Feed  Feeds for this forum: RSS   JS   XML



Page generated in 0.14684 seconds with 12 queries