Solved

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

Posted on 2003-10-29
9
138 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
New! My Passport Wireless Pro Wi-Fi Mobile Storage

Portable wireless storage to offload, edit, and stream anywhere.

High-capacity, wireless mobile storage designed to accompany professional photographers and videographers in the field to easily offload, edit and stream captured photos and high-definition videos.

 

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

Scale it in WD Gold

With up to ten times the workload capacity of desktop drives, WD Gold hard drives employ advanced technology to deliver among the best in reliability, capacity, power efficiency and performance.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Article by: kevp75
Hey folks, 'bout time for me to come around with a little tip. Thanks to IIS 7.5 Extensions and Microsoft (well... really Windows 8, and IIS 8 I guess...), we can now prime our Application Pools, when IIS starts. Now, though it would be nice t…
Introduction This article explores the design of a cache system that can improve the performance of a web site or web application.  The assumption is that the web site has many more “read” operations than “write” operations (this is commonly the ca…
I designed this idea while studying technology in the classroom.  This is a semester long project.  Students are asked to take photographs on a specific topic which they find meaningful, it can be a place or situation such as travel or homelessness.…
With Secure Portal Encryption, the recipient is sent a link to their email address directing them to the email laundry delivery page. From there, the recipient will be required to enter a user name and password to enter the page. Once the recipient …

919 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

19 Experts available now in Live!

Get 1:1 Help Now