473,569 Members | 2,472 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

select a folder with option select in php

137 New Member
Hello guys,
I'm busy with an photogallery and i wanted to implent this script i wrote to select a folder and put there the photo's in.
But i only get 1 folder in the drop-down menu and the other is standing next to it.
If i do print_r ($folders); then the folders are side by side and the array has only index[0].
Anybody an idea?

this is my script:

[PHP]<? echo "<select name=\"selectee r folder\" size=\"1\" >";
$dir = ".";
$dp = opendir ($dir);
while ($folder = readdir($dp)){
if((is_dir($fol der)) AND (substr($folder ,0,1)!='.')){
$folders = explode (' ', $folder);
foreach ($folders as $index => $map){
echo "<option value=\"$index\ ">$map</option>";
echo "</select>";
$aantal = count ($folders); //For showing how many folders there are...(later use)
}
}
}
?>[/PHP]

Gr Paul
Feb 6 '07 #1
3 12375
ronverdonk
4,258 Recognized Expert Specialist
You misplaced the end of select </select> statement. It should be outside the while loop\. I don't know what you want to do with the $aantal, so I left it where it was.

[php]<?
echo "<select name=\"selectee r folder\" size=\"1\" >";
$dir = ".";
$dp = opendir ($dir);
while ($folder = readdir($dp)){
if((is_dir($fol der)) AND (substr($folder ,0,1)!='.')){
$folders = explode (' ', $folder);
foreach ($folders as $index => $map){
echo "<option value=\"$index\ ">$map</option>";
$aantal = count ($folders); //For showing how many folders there are...(later use)
}
}
}
echo "</select>";
?>[/php]
Ronald :cool:
Feb 6 '07 #2
djpaul
137 New Member
well, $aantal means total.
That one shows how many folders you have created.
You can cut it out...
but the problem is that.. hmm wait, an example:

these are the folders:
football
Holiday
Wedding

if i show the array it looks like this:
array([0}=>footbal) Holidayarray ([0]=>Holiday) Weddingarray([0]=>Wedding)

but it suposed to be:
array ([0]=>footbal [1]=>Holiday [2]=>Wedding)
Feb 6 '07 #3
ronverdonk
4,258 Recognized Expert Specialist
Ik weet dat aantal total betekent.

The position of the $aantal assignment looks useless to me, because you fill that variable each time the foreach loop is executing. So at the end you have the value of the last assignment in variable $aantal.

Also, if you want to show the text 'Selecteer folder' in the top of your drop-down box, you must specify that text in the first <option> statement, along with a value of nil. Like this:[php]<?php
echo "<select name=\"selectee r folder\" size=\"1\" >";
echo "<option value=''>Select eer folder</option>";
$dir = ".";
... etc ....[/php]
Ronald :cool:
Feb 7 '07 #4

Sign in to post your reply or Sign up for a free account.

Similar topics

1
5233
by: JT | last post by:
I have an input form for which I've created a "matrix" for user input. Basically, the user chooses a radio button and then through javascript, a select box is displayed to define a value for that radio option, like so: Choice: (Radio1) type: (select box1) Choice: (Radio1) type: (select box2) Choice: (Radio1) type: (select box3) Choice:...
4
6423
by: point | last post by:
Hello there... I'm a PHP programmer and starting to learn JS... I have a following problem.... I have 3 select boxes! one is hotel one is destination and one is country... if someone clicks selects the country then the destination select box shows the destinations in that country and further if he chooses destination all
3
16410
by: gekoblu | last post by:
Hi!, I want to fix via javascript the combo width to a fix value. I'd like to implement a kind of ALT / TITLE function to show the entire option when the text is longer than the combo width... It's possible?!? Thanks
4
3856
by: Marek Mänd | last post by:
This seems an IE issue only: 4253 bytes testcase: http://www.hot.ee/idaliiga/testcases/ieselect/bnlinkingselectinmsie.htm Can one have 1) a mouseover/mouseout element on TBODY 2) change in thoise event handler background colors 3) have a specified heighted SELECT element, that doesnt flicker when the event handlers are get called.
4
12043
by: MC D | last post by:
What's the best way to have a modal dialog that will only allow the selection of a FOLDER, rather than a file? Is there a property of the openFileDialog I'm missing, or is there another control altogether? I was thinking of doing it from a treeView, but It seems like there ought to be a control for this sort of thing! -D
7
55769
by: Sakharam Phapale | last post by:
Hi All, I want to give option to user for selecting directory, just like for selecting file using OpenFileDialog control. How to make it possible?
9
51973
chunk1978
by: chunk1978 | last post by:
hey everyone, i've been trying to solve this problem for 2 days straight, with no end in sight. i would greatly appreciate anyone's help. EXPLANATION: There are 3 Select Menus. The 1st and 2nd Select Menu are "printing options" for 4x6 and 5x7 prints respectively. the 3rd Select Menu holds an "Email" option that can be toggled...
17
4823
by: irfan200x | last post by:
Folder Option Hi All, I have the new type problem in folder option where should i get this problem through Flash Drive Plug into USB port and its Shows ON and OFF in the Windows XP SP2. and automatically generate the virus or some thing else my folder option show all files not working and when i click my computer ICON and click to Hard Drive...
0
2126
by: pradheepayyanar | last post by:
hey i have an requirement which should select a folder in the web browser. i have an <input> element with <input type="file" name="file" accept="text/plain"> normally the type=file will accept only one file @ a time. i need to select a folder. is that possible. if so how to do abt tat. if not wats the alternate option
0
7703
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main...
0
7926
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. ...
1
7679
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For...
0
7983
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the...
0
6287
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then...
1
5514
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes...
0
5223
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert...
1
2117
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
0
946
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.