Adobe Dreamweaver Forums



Last 10 THreads :         Pop up window using AS3 (Last Post : retsnomrev - Replies : 1 - Views : 2 )           »          CS4 - annoying help system (Last Post : Rothrock - Replies : 9 - Views : 10 )           »          My bullets dont work in my game >.< (Last Post : kglad - Replies : 1 - Views : 4 )           »          flash movie plays prematurely (Last Post : kglad - Replies : 6 - Views : 7 )           »          Image Fade Out/Load new Image/Fade In (Last Post : EWN-CMI - Replies : 0 - Views : 1 )           »          Recommend Reading? (Last Post : anpuofeck - Replies : 5 - Views : 7 )           »          static sound (Last Post : kglad - Replies : 15 - Views : 16 )           »          Detect multiple areas of transparency in an image? (Last Post : Rothrock - Replies : 8 - Views : 9 )           »          Add a full screen button to a video. (Last Post : kglad - Replies : 5 - Views : 11 )           »          Problems when uploading my website (Last Post : speculumcm - Replies : 4 - Views : 5 )           »         


Home Register FAQ Members List Calendar Search Today's Posts Mark Forums Read
User Info Statistics
Go Back   Adobe Dreamweaver Forums > Macromedia Software > Cold Fusion > Getting Started
 
Tags:



Reply
  #1 (permalink)  
Old 11-21-2008, 08:36 PM
andy99
 
Posts: n/a
Diggs:
Default Question about filtering commas

Sorry for this newbie questions.

I have a simple quetions where people can answer
What flavor ice cream you want? and they can select mutiple ones
<select multiple size="12" name="icecream">
<option value="vanilla" selected>Vanilla
<option value="choco" selected>Choco
<option value="mango" selected>mango
<option value="coffe" selected>coffe
<option value="fudge" selected>fudge
</select>

Now the data get stored as a comma delemeted for example, vanilla,choco,fudge

I need to allow the users to edit their selection if they want to.
So when I query the field from the DB the value comes back as above (comma
delemeted).
I can add a CFloop to return each on one line.
Now my question is how can I make let people see what they have selected
before and in the form where they can modify their selection. When I add the
loop and cfif statment, I get the selections repeated few time.
So I want to have the select stament above with the option SELECTED if the
user have chosen that flavor before.

Again I have not programmed in years and very rusty with this.
Any help is appreciated.



Reply With Quote
Sponsored Links
  #2 (permalink)  
Old 11-21-2008, 08:44 PM
Ian Skinner
 
Posts: n/a
Diggs:
Default Re: Question about filtering commas

The listFind() and listContains() functions.

andy99 wrote:
>
> Now the data get stored as a comma delemeted for example, vanilla,choco,fudge
>


That is a really bad database design choice. It will not scale and
there are a lot of normal database functionality one will find very
difficult, if not down right impossible with this. One should not store
a list of values in a field in a database.

This just screams for normalization where you create a related table of
User_Flavors that contains the ids of the user and their chosen flavors,
one record per flavor per user. This would then join the users table to
the flavors table.

Just warning you, you are heading down a road that quickly leads to
difficulty. Just search these list for databases and list values to see
some of the trouble this causes.
Reply With Quote
  #3 (permalink)  
Old 11-21-2008, 09:34 PM
andy99
 
Posts: n/a
Diggs:
Default Re: Question about filtering commas

Thanks Ian. Yeah, I was trying to avoid checkboxes and thought this will be an
easy way out.
Since this is a very small application (user id and flavor) I thought it will
be simpler.

So I tried the 2 functions but they both return 0.
<cfquery datasource="shop" name="mydb">
select * from icecream
where id like 'form.id'
</cfquery>

<cfoutput query="mydb">
#ListFind(ice, ",")#
</cfoutput>

Again, I would like to output them in the option fields and if they selected
originall then I will add CHECKED to the option.

Reply With Quote


  #4 (permalink)  
Old 11-21-2008, 09:43 PM
Ian Skinner
 
Posts: n/a
Diggs:
Default Re: Question about filtering commas

andy99 wrote:
> Thanks Ian. Yeah, I was trying to avoid checkboxes and thought this will be an
> easy way out.
> Since this is a very small application (user id and flavor) I thought it will
> be simpler.
>
> So I tried the 2 functions but they both return 0.
> <cfquery datasource="shop" name="mydb">
> select * from icecream
> where id like 'form.id'
> </cfquery>
>
> <cfoutput query="mydb">
> #ListFind(ice, ",")#
> </cfoutput>
>
> Again, I would like to output them in the option fields and if they selected
> originall then I will add CHECKED to the option.
>

Reply With Quote
  #5 (permalink)  
Old 11-21-2008, 09:54 PM
Ian Skinner
 
Posts: n/a
Diggs:
Default Re: Question about filtering commas

andy99 wrote:
> <cfoutput query="mydb">
> #ListFind(ice, ",")#
> </cfoutput>


That is not a complete list find function. At least not complete enough
to do what you want. I suspect that it is trying to find a value of a
comma. I would expect something that looked like this.

#listFind(mydb.ice,"chocolate")#

OR if you like to be complete.

#listFind(mydb.ice,"chocolate",",")#

And then your select code would look something like this.

<select ...>
<option #iif(listFind(mydb.ice,"chocolate"),
DE('selected="selected"'), DE(''))# value="chocolate">Chocolate</option>
<option #iif(listFind(mydb.ice,"vanilla"), DE('selected="selected"'),
DE(''))# value="vanilla">vanilla</option>
....
</select>
Reply With Quote
  #6 (permalink)  
Old 11-21-2008, 10:44 PM
andy99
 
Posts: n/a
Diggs:
Default Re: Question about filtering commas

Now I see what I was doing wrong.
Thanks again IAN for your help. Much appreciated.
Cheers
Reply With Quote


Reply


Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On



© Camley Interactive (camley.info) 2008 - all logos and images are copywrite their respective owners.
Proud member of the Camley Interactive Network
All times are GMT. The time now is 06:57 AM.


Powered by vBulletin® Version 3.6.8
Copyright ©2000 - 2009, Jelsoft Enterprises Ltd.
Search Engine Friendly URLs by vBSEO 3.1.0 ©2007, Crawlability, Inc.
Cheap Car Insurance - Compare Motor Insurance
Endsleigh Car Insurance Natwest Car Insurance
More Than Car Insurance Norwich Union Car Insurance
Prudential Car Insurance Zurich Car Insurance
Inactive Reminders By Mished.co.uk