Hi all
I have a field in my database that is one long list. I want to put this list into a drop down but have each item in that list its own option.
This is how its printing at the moment: - <select name="v_options"><option value="">-- Any --</option><option value='34'>Allerton, Bolton, Bolton Woods,Bowling,Bradford Moor,Buttershaw,Clayton,Dudley Hill,East Bierley</option></select>
- <select name="v_options"><option value="">-- Any --</option>
-
<option value='34'>Allerton, Bolton</option><option value='34'>Bolton Woods</option><option value='34'>Bowling</option><option value='34'>Bradford Moor</option><option value='34'>Buttershaw</option><option value='34'>Clayton</option>Dudley Hill<option value='34'>East Bierley</option></select>
Does anyone know a function that will separate my options?
Thanks
xx
5 1170
Hi all
I have a field in my database that is one long list. I want to put this list into a drop down but have each item in that list its own option.
This is how its printing at the moment: - <select name="v_options"><option value="">-- Any --</option><option value='34'>Allerton, Bolton, Bolton Woods,Bowling,Bradford Moor,Buttershaw,Clayton,Dudley Hill,East Bierley</option></select>
- <select name="v_options"><option value="">-- Any --</option>
-
<option value='34'>Allerton, Bolton</option><option value='34'>Bolton Woods</option><option value='34'>Bowling</option><option value='34'>Bradford Moor</option><option value='34'>Buttershaw</option><option value='34'>Clayton</option>Dudley Hill<option value='34'>East Bierley</option></select>
Does anyone know a function that will separate my options?
Thanks
xx
you can try explode(), and then make a loop to builed your html code from the array
post a sample of your db filed value
i dont think i understood in 100% what u want to do :(
Yeh, like he/she said.
Say we have a string (coming from your db), each word is seperated by a space.
[php]
$_string = "list of places in string seperated by spaces";
[/php]
We'd then explode() the string with a space ' ' as a delimiter, to make turn the string into an array
[php]
$_string = explode(" ", $_string);
[/php]
Then we'd use a foreach() loop to traverse through the array:
[php]
foreach( $_string as $_x )
{
echo $_x . "<br />";
}
[/php]
Hope this helps!
Hi,
if the field is in a MySQL DB why not use this to populate your dropdown?
[PHP]<?
mysql_select_db($database, $connect);
$tablename = "event";
$abfrage = "SELECT datum, event FROM $tablename ORDER BY datum ASC";
$ergebnis = mysql_query($abfrage);
echo '<select size="1" name="datum">';
while($row = mysql_fetch_object($ergebnis))
{
$datum = "$row->datum";
$event = "$row->event";
echo '<option value="'.$datum.'">'.$datum. ' : ' .$event.'</option><br>'; // Eleganter
$event = $_POST['event'];
$datum = $_POST['datum'];
}
echo $datum;
echo ' </select>';
?>[/PHP]
In this case, I have populated the dropdown with "Datum : Event"
Hope this helps,
Best regards,
Stefan
Hi guys!
Thats brilliant! I have used the explode () function and it works perfectly.
Thanks again
Laz
xxx
Hi guys!
Thats brilliant! I have used the explode () function and it works perfectly.
Thanks again
Laz
xxx
Welcome!
Post back again whenever :)
Sign in to post your reply or Sign up for a free account.
Similar topics
by: Anon Email |
last post by:
Hi people,
I'm learning about header files in C++. The following is code from
Bartosz Milewski:
// Code
const int maxStack = 16;
class IStack
|
by: Joe Laughlin |
last post by:
If I have a character array with "/some/file/directory/file_name", are there
any functions / libraries that I could use to separate the directory
("some/file/directory") from the file name...
|
by: Chad Z. Hower aka Kudzu |
last post by:
I want to do this.
I want my programmers to do all the code. All of it - run at server and run
at client.
I then want a graphic artist to make the look and the layout of the pages.
The...
|
by: mca |
last post by:
Hi everyone,
I'm new to asp.net and i have a question about separating the html
code from the programming code.
i have an unknown numbers of entries in my table. I want to make a
hyperlink...
|
by: Michelle |
last post by:
Hi all... I could use a little TLC here for understanding and not for
solving a specific problem... sorry if I've got the wrong group, but I'm
using VB so I figured this was the most appropriate...
|
by: Jeff S |
last post by:
Please note that this question is NOT about any particular pattern - but
about the general objective of separating out presentation logic from
everything else.
I'm trying to "get a grip" on some...
|
by: Thag |
last post by:
Hi!
I am currently trying to get an overview about the possibility of
separating graphical data from its animations.
More specifically speaking, the graphical data is made up from 3D-CAD...
|
by: aaragon |
last post by:
Hi everyone,
I've been writing some code and so far I have all the code written in
the .h files in order to avoid the linker errors. I'm using templates.
I wanted to move the implementations to...
|
by: Gilles Ganault |
last post by:
Hi
One of the ways to raise performance for PHP apps is to
separate static contents from dynamic contents, so that the former can
be compiled once into cache.
Can someone give me a simple...
|
by: Charles Arthur |
last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
|
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
|
by: nemocccc |
last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
|
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...
|
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...
|
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,...
|
by: jinu1996 |
last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
|
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...
|
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...
| |