Link to home
Start Free TrialLog in
Avatar of megakingbob
megakingbob

asked on

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  

e.g.
        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
Avatar of alexhogan
alexhogan

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;
400+40000+8000

Avatar of megakingbob

ASKER

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

I am an absolute beginner :-)
Avatar of Ryan Chong
Do you have any existing scripts where you can post here?
ASKER CERTIFIED SOLUTION
Avatar of alexhogan
alexhogan

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial