Go Premium for a chance to win a PS4. Enter to Win

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 179
  • Last Modified:

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???

Thanks
Steve
0
sdowns1122
Asked:
sdowns1122
  • 3
  • 3
1 Solution
 
proceptCommented:
Hi,

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. ;-))

Chris
0
 
PE_CF_DEVCommented:
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 ,
      CONSTRAINT [PK_Bullets] PRIMARY KEY  CLUSTERED
      (
            [Product_Bullet_ID]
      )  ON [PRIMARY]
) ON [PRIMARY]
GO

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.
0
 
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.
0
Free Tool: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

 
sdowns1122Author Commented:
PE_CF_DEV

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.
0
 
PE_CF_DEVCommented:
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.
</cfloop>

0
 
sdowns1122Author Commented:
PE_CF_DEV

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.
0
 
PE_CF_DEVCommented:

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#')
</cfquery>
</cfloop>



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,"|")>
</cfloop>
<cfquery stuff>
Update products
set bullets='#bulletlist#'
where product_id=#id from somewhere#
</cfquery>
0

Featured Post

Free Tool: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

  • 3
  • 3
Tackle projects and never again get stuck behind a technical roadblock.
Join Now