Pulling data from a table cell, adding to a list, then displaying it on the page

Hi all,

I'm creating a CMS, and I have a question:
I want to be able to enter data into a form, have it post to the DB. Then, when the data is called by CF, I need to display it in a bullet list. However, the number of bullets in that list will always be different. I'm not sure if I should create a column for each bullet, or if I could use one column for all of the bullets, then put those bullets in a list, with a certain delimiter, and display them that way. If I create one column per bullet, I'd have to create enough columns to cover any number of bulets, but that seems inefficient. Anyone have any ideas???

Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.


could you explain a bit more ?

You insert data into a DB and later select that data, then you want to display it, that's how far I got. ;-))

What do you want to display in a bulleted list? All fields from one record or all records from the query??? Something else??

I'm sure it can be done quite easily, but, right now I don't know what you mean. ;-))

Few Possible solutions to this one.

The best solution is creat a new table for the bullets.

CREATE TABLE [Bullets] (
      [Product_Bullet_ID] [int] IDENTITY (1, 1) NOT NULL ,
      [Product_id] [int] NOT NULL ,
      [Bullet] [nvarchar] (500) COLLATE SQL_Latin1_General_CP1_CI_AS NOT NULL ,
      )  ON [PRIMARY]

Then query for the bullets and loop through that query.

The biggest problem you might run into by storing all bullets in one column would be the delim. If you choose to fo this route I would recomed using something like | as the delim. The you just loop through that colum using | as the delim. And additional problem you might run into is the column length, it may not be able to hold that many bullets...

If you need some additional code let me know I'll be more than happy to post some further code.
sdowns1122Author Commented:
Well someone would enter the different bullet points into a textbox ( I haven't dedided whether or not it shoul dhave one text box for each bullet point, or a general textarea box for all of the points.) on a form. If I have them insert all of the bullet points together into one table cell in the DB, how would I have CF divide the points up to display as separate points? Hopefully this clears things up a bit.
10 Tips to Protect Your Business from Ransomware

Did you know that ransomware is the most widespread, destructive malware in the world today? It accounts for 39% of all security breaches, with ransomware gangsters projected to make $11.5B in profits from online extortion by 2019.

sdowns1122Author Commented:

I thought about devoting one column in my row to the bullet points, then looping through the query to display them. For some reason it didn't work. Another thing I'm trying to figure out is if other employees are trying to enter this info into the DB through a form, how do I designate the bullet points from each other?
I also could have separate columns for each point, but then I'd have to create at least 40 or so columns to accomodate all of the points.
Your best bet is to make each bullet point a seperate input box on the form. Otherwise you will have to teach you're people entering the info how to put the | (or whatever) between each bullet point. From my experience data entry people are some of the lowest forms of semi intellegent workers in an office (no offence to anyone out there reading :))so you want to keep it as easy as possible. In our CMS we we restrict them to 30 bullet points which should be enough.... If it is not then you best bet is do something like this. Have a simple form where they enter the # of bullets they want, and submit it, then on the next page create those text inputs dynamically...

Something like
<input type=hidden name=number value= form.input>
Loop from 1 to form.input
   input name=bullet#index#
end loop

Then on the next page
<cfloop from=1 to=form.number step=1 index=ind>
       <cfset bullet = "form.bullet#ind#">
       <cfset bullet = evaluate(bullet)>
       At this point "bullet" holds the information for the current bullet, you can do whatever you want.

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
sdowns1122Author Commented:

Thats exactly what I'm talking about, I don' thave time to make sure they enter the "|" between each point. Your idea of asking them how many they have, then supplying them with the appropriate # of text boxes is a good one. Then I would need a separate column for each bullet point, but if thats what it takes. I might stick with just listing a certian # of boxes, they can fill out however many they want. Thanks for the code too, I'll keep it on hand.
Thanks for the advice too, you helped make it a bit easier.

Yoo don't need a seperate colum you could create a new table to hold them. Then to output them you query the table:

Select *
from product_Bullets
where product_id=#id passed from somewhere#

<cfloop from=1 to=form.number step=1 index=ind>
       <cfset bullet = "form.bullet#ind#">
       <cfset bullet = evaluate(bullet)>
      <!---  At this point "bullet" holds the information for the current bullet, you can do whatever you want. --->
<cfquery stuff>
insert into Product_bullets (product_id,bullet)
VALUES ('#product_id#','#bullet#')

or if you wanted to stick to the same collum trick...:
<cfset bulletlist="">
<cfloop from=1 to=form.number step=1 index=ind>
       <cfset bullet = "form.bullet#ind#">
       <cfset bullet = evaluate(bullet)>
     <!--- At this point "bullet" holds the information for the current bullet, you can do whatever you want. --->
     <cfset bulletlist=listappend(bulletlist,bullet,"|")>
<cfquery stuff>
Update products
set bullets='#bulletlist#'
where product_id=#id from somewhere#
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Web Servers

From novice to tech pro — start learning today.