Seperating data from single table field (string)

V

vool

Hi All

Can anyone help with this please.

I need a way of putting say 10 to 20 bullet points in one table field in an
Access database
- say seperate them with a special character, then build a bulletted list on
my page.

If I can get the page to detect each special character, insert a new bullet
and move on to the next occurance in the string...

e.g. point01%point02%point03%point04%point05%point06

to...

<ul>
<li>point01</li>
<li>point02</li>
<li>point03</li>
<li>point04</li>
<li>point05</li>
<li>point06</li>
</ul>

Many thanks in advance

vool
 
A

Alan

Just store the terms as a comma separated list (or use a more robust
placeholder if commas are likely to appear in any term). When you retrieve
this string from the database split it on the placeholder, which generates
an array, and iterate through creating your HTML:

MyStringTerm = RS.Fields("MyString") ' contains "alpha,bravo,charlie"
MyStringArray = Split (MyStringTerm, ",") ' contains
("alpha","bravo","charlie")
Response.Write "<ul>"
For Each Term In MyStringArray
Response.Write "<li>"
Response.Write Term
Response.Write "</li>"
Next
Response.Write "</ul>"

Alan
 
B

Bob Barrows

I'm glad Alan answered your questions, but I want to add that it's usually a
bad idea to store multiple pieces of data in a single field. This is a basic
tenet of proper database design. A better idea would be to create a separate
table with a one-to-many relationship between the original table and the new
table, allowing you to store each peice of data in its own row in the new
table.

You may be thinking that the list itself is a single piece of data, but this
is belied by the fact that you need to string together multiple pieces of
data to form it.

HTH,
Bob Barrows
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
474,083
Messages
2,570,590
Members
47,211
Latest member
JaydenBail

Latest Threads

Top