Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium


Collecting data from a table

Posted on 2005-03-28
Medium Priority
Last Modified: 2010-04-25
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
Question by:megakingbob
  • 2

Expert Comment

ID: 13647647
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;


Author Comment

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

I am an absolute beginner :-)
LVL 55

Expert Comment

by:Ryan Chong
ID: 13653563
Do you have any existing scripts where you can post here?

Accepted Solution

alexhogan earned 2000 total points
ID: 13654299

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.

Featured Post

Free Tool: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

For those who don't know, Adobe Dreamweaver is a popular commercial web editor that enables you to design, build and manage complex websites. The editor is a WYSIWYG (What You See Is What You Get) web editor, which means that you can create your web…
I still run into .cgi files every now and then. In some instances, I actually prefer the simplicity of a .cgi script to other options. Since I use DreamWeaver extensively, what I needed was a way to open .cgi scripts in Dreamweaver. And I wanted to …
In a question here at Experts Exchange (https://www.experts-exchange.com/questions/29062564/Adobe-acrobat-reader-DC.html), a member asked how to create a signature in Adobe Acrobat Reader DC (the free Reader product, not the paid, full Acrobat produ…
This lesson discusses how to use a Mainform + Subforms in Microsoft Access to find and enter data for payments on orders. The sample data comes from a custom shop that builds and sells movable storage structures that are delivered to your property. …
Suggested Courses
Course of the Month14 days, 10 hours left to enroll

577 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