Collecting data from a table

I have some data in a table, i would like to collect all the data in one column so that the data can be copied else where  

        name weight
        fish     400
        cow    40000
        man    8000

i would like the 400, 40000 and 8000 collected and copied elsewhere (such as a textbox in the same page) as text as well as a + sign between them  "400+40000+8000"

Any advice please
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.

Rreturning the contents of a field is easy.  You would set your query to get that information.

Depending on what server side language you're using taking that data and formatting it is pretty easy and straight forward as well.  You will want to put the results in an array and then parse the array, replacing the commas with your plus sign.

Using PHP lets query the database and get the returned results, parse the data and print out to the screen.

$query   =   "SELECT myField
                   FROM myTable";

$result   =   mysql_query($query) or die;

while($row     =   mysql_fetch_assoc($result)){
    $myArray[] =   $row['myField'];

echo implode('+', $myArray);

This will return and print to the screen something like;

megakingbobAuthor Commented:
i should have said i'm using ASP JavaScript and where would i put this code

I am an absolute beginner :-)
Ryan ChongCommented:
Do you have any existing scripts where you can post here?

In ASP....

'Assign Database Connection String And Location
dbString = "Provider=Microsoft.Jet.OLEDB.4.0; Data Source=" & Server.MapPath("/foldername/cars.mdb")

'Creating A Connection Object
Set conn = CreateObject("ADODB.Connection")
sConn.Open dbString

'Assign Variable To Store Database Results
sResult = CreateObject("ADODB.Recordset")
sResult.Open "SELECT myField FROM myTable, sConn

'Dimension an array and a counter variable
Dim myArray()
Dim i

i  =  1

Do While Not result.EOF
  myArray(i)  =  sResult.Field("myField").Value
  i  =  i + 1

' A new string to hold the returned value
Dim myNewString

myNewString  =  Replace(myArray, ",","+")


I haven't tried this code but it should work.

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
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
Adobe Dreamweaver

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.