Dynamic Drop Down Menu

I need to create a dynamic drop down menu which is populated by entries such as;

htdocs/client1/index.php
htdocs/client2/index.php
htdocs/client3/index.php
htdocs/client4/index.php
etc.

So htdocs/client*/index.php

Is this possible?

I know how to do this using normal arrays, but not sure if a dynamic drop down would be possible without using a DB.

Just use a bash/ksh script.

#!/bin/ksh
#clientlist
list=`ls -d client*`
i=1
for file in $list
do
if [ -d $list ]
then
echo \<option value="i"\>  $list\</option\>
i=`expr $i + 1`
fi
done
<select name="client" size="1">
<?php `clientlist` ?>
</select>

I didn't check the syntax of the echo statement for meta characters.

Sorry for the delayed reply. I have added this into my index however made a slight change to the shell script so it didnt loop within itself;

#!/bin/sh
list=`ls -d /*`
i=1
for file in $list
do
if [ -d $file ]
then
echo \<option value="i"\>  $file\</option\>
i=`expr $i + 1`
fi
done

However which ever way I do it the drop down menu just comes back blank.

Any ideas?

Thanks :smiley:

---------- Post updated at 04:27 PM ---------- Previous update was at 02:17 PM ----------

Managed to get it working using;

for list in `ls -d /usr/local/apache2/htdocs/services/* | sed 's/\// /g' | awk {'print $6'}`;
        do
                if [ -d $file ];
                then
                        echo '<option value="'/cgi-bin/$list.sh'">'$list'</option>'
                fi
        done