Solved

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

Posted on 2003-10-29
9
128 Views
Last Modified: 2013-12-24
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
Comment
Question by:sdowns1122
  • 3
  • 3
9 Comments
 
LVL 4

Expert Comment

by:procept
ID: 9642596
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
 
LVL 6

Expert Comment

by:PE_CF_DEV
ID: 9642627
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
 

Author Comment

by:sdowns1122
ID: 9642649
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
Highfive + Dolby Voice = No More Audio Complaints!

Poor audio quality is one of the top reasons people don’t use video conferencing. Get the crispest, clearest audio powered by Dolby Voice in every meeting. Highfive and Dolby Voice deliver the best video conferencing and audio experience for every meeting and every room.

 

Author Comment

by:sdowns1122
ID: 9642736
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
 
LVL 6

Accepted Solution

by:
PE_CF_DEV earned 125 total points
ID: 9642925
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
 

Author Comment

by:sdowns1122
ID: 9643344
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
 
LVL 6

Expert Comment

by:PE_CF_DEV
ID: 9643508

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

Network it in WD Red

There's an industry-leading WD Red drive for every compatible NAS system to help fulfill your data storage needs. With drives up to 8TB, WD Red offers a wide array of solutions for customers looking to build the biggest, best-performing NAS storage solution.  

Join & Write a Comment

A web service (http://en.wikipedia.org/wiki/Web_service) is a software related technology that facilitates machine-to-machine interaction over a network. This article helps beginners in creating and consuming a web service using the ColdFusion Ma…
Periodically we have to update or add SSL certificates for customers. Depending upon your hosting plan you may be responsible for the installation and/or key generation. In the wake of Heartbleed many sites were forced to re-key. We will concen…
When you create an app prototype with Adobe XD, you can insert system screens -- sharing or Control Center, for example -- with just a few clicks. This video shows you how. You can take the full course on Experts Exchange at http://bit.ly/XDcourse.
This video explains how to create simple products associated to Magento configurable product and offers fast way of their generation with Store Manager for Magento tool.

744 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

11 Experts available now in Live!

Get 1:1 Help Now