Solved

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

Posted on 2003-10-29
9
167 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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
Moving data to the cloud? Find out if you’re ready

Before moving to the cloud, it is important to carefully define your db needs, plan for the migration & understand prod. environment. This wp explains how to define what you need from a cloud provider, plan for the migration & what putting a cloud solution into practice entails.

 

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

Get 15 Days FREE Full-Featured Trial

Benefit from a mission critical IT monitoring with Monitis Premium or get it FREE for your entry level monitoring needs.
-Over 200,000 users
-More than 300,000 websites monitored
-Used in 197 countries
-Recommended by 98% of users

Question has a verified solution.

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

In our day to day coding, how many times have we come across a necessity to check whether a URL is a broken link or not? For those of you that answered countless and are using ColdFusion like myself, then this article is for you.  It will show yo…
Lease-to-own eliminates the expenditure of hardware replacement and allows you to pay off the server over time. Usually, this is much cheaper than leasing servers. Think of lease-to-own as credit without interest.
Monitoring a network: why having a policy is the best policy? Michael Kulchisky, MCSE, MCSA, MCP, VTSP, VSP, CCSP outlines the enormous benefits of having a policy-based approach when monitoring medium and large networks. Software utilized in this v…
Do you want to know how to make a graph with Microsoft Access? First, create a query with the data for the chart. Then make a blank form and add a chart control. This video also shows how to change what data is displayed on the graph as well as form…

623 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