How to make an unordered list from a database record?

I'm currently working on a real estate application and I need to populate information on a detail page with bulleted (unordered list) details about the house. The process works like this, user fills out an input form to insert the listing into the database, the database returns information on detail page.

The problem I'm having is- Being that the bulleted list will vary with each house I can't have a set number of feilds (bullet1 feild, bullet2 field and so on) so I was thinking of using a multiline text feild on the form page and inserting the bulleted list and hopeing to parse out each bullet (list item) by checking for a carrige return in the database record. I have no idea how to go about doing such a thing.

Recap, I need a way to auto popluate bulleted text from one record in a database (text with carriage returns. I hope this make sense.
LVL 1
jasch2244Asked:
Who is Participating?
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.

azadisaryevCommented:
this does make sense, and is easily done. all you need to do is treat your text as a cr/lf-delimited list and cfloop over it:

<cfoutput>
<ul>
<cfloop list="#myquery.textfield#" index="line" delimiters="#chr(13)&chr(10)#">
<cfif len(trim(line))><li>#line</li></cfif>
</cfloop>
</ul>
</cfoutput>

but you should consider modifying your data model to store each detail (your bulleted item) as a separate record in a house-details table, linked to the house via some house_id foreign key. this will be easier to manage and will make your db more normalized...

hth
0
jasch2244Author Commented:
Thank you for your quick response (wow). Oh please hang with me here...
I am somewhat familiar with cfloop in that it loops over a list or query what have you. Is what you are proposing using a multiline text feild with content like [ this is a great house --line break--- the foyer is beautiful--line break] where at each line break the loop will create an li tag?

Just not sure what #chr(13)&)&chr(10)# or <cfif len(trim(line))><li>#line</li> does.

The data is contained in mysql in a varchar (255 characters).
0
azadisaryevCommented:
yes, that's what the code will do.
assuming your db field contains text like:
this is a great house[linebreak]
the foyer is beautiful[linebreak]
[something else about the house] is [great|wonderful|outstanding|spectacular|etc]

the code will output the above as
<li>this is a great house</li>
<li>the foyer is beautiful</li>
<li>[something else about the house] is [great|wonderful|outstanding|spectacular|etc]</li>

a few explanations of the code:
#chr(13)&chr(10)# is ascii code for CR [chr(13)] and LF [chr(10)] characters;
#line# is the index assigned in the cfloop, and represents each ine in your text field as it is being looped over;
<cfif len(trim(line))> checks that the length of current line is > 0. it is shorthand for <cfif len(trim(line)) gt 0>;

hth

0

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
jasch2244Author Commented:
Thank you master! You have helped me in the past and I am forever greatful for your knowledge.

Thank you, thank you
0
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.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.