473,396 Members | 2,102 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

select a folder with option select in php

137 100+
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=\"selecteer folder\" size=\"1\" >";
$dir = ".";
$dp = opendir ($dir);
while ($folder = readdir($dp)){
if((is_dir($folder)) 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 12332
ronverdonk
4,258 Expert 4TB
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=\"selecteer folder\" size=\"1\" >";
$dir = ".";
$dp = opendir ($dir);
while ($folder = readdir($dp)){
if((is_dir($folder)) 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 100+
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 Expert 4TB
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=\"selecteer folder\" size=\"1\" >";
echo "<option value=''>Selecteer 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
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...
4
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...
3
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......
4
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...
4
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...
7
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
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...
17
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...
0
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...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
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,...
0
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...
0
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...
0
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,...

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.