4 Replies - 4998 Views - Last Post: 01 March 2010 - 12:25 PM Rate Topic: -----

#1 mpryan73  Icon User is offline

  • New D.I.C Head

Reputation: 1
  • View blog
  • Posts: 39
  • Joined: 05-February 10

Insert Table into database and get row number

Posted 05 February 2010 - 02:11 AM

I have a table that I need to insert into a database. It currently has only one field.

<tr><td>bla bla</td></tr>
<tr><td>bla bla2</td></tr>
<tr><td>bla bla3</td></tr>


Is it possible to insert the row position in the table to a database field and then the field value. So for the table above I need the records in the database to be

Row #, Bla_Bla_Value

1 bla bla
2 bla bla2
3 bla bla3

Does this make sence?

Is This A Good Question/Topic? 0
  • +

Replies To: Insert Table into database and get row number

#2 Craig328  Icon User is offline

  • I make this look good
  • member icon

Reputation: 1926
  • View blog
  • Posts: 3,471
  • Joined: 13-January 08

Re: Insert Table into database and get row number

Posted 05 February 2010 - 01:27 PM

It sounds as though you're confusing an HTML table with a database table (looks like that anyway).

That said, yes you can create a table in a database and then insert records using an ID number (what you called a row number) and a value. You can set up the database to auto-increment the id value of the record so that you don't have explicitly tell the database what the "row value" is. Any online resource regarding T-SQL would be a good place to start (SQL being the language that allows you to work with databases and their data).
Was This Post Helpful? 0
  • +
  • -

#3 mpryan73  Icon User is offline

  • New D.I.C Head

Reputation: 1
  • View blog
  • Posts: 39
  • Joined: 05-February 10

Re: Insert Table into database and get row number

Posted 06 February 2010 - 02:23 AM

Sorry Craig I was not very clear. I have a html page with a table on it and I want to scrap it basicly and insert the data into a database.
Was This Post Helpful? 0
  • +
  • -

#4 xheartonfire43x  Icon User is offline

  • D.I.C Regular

Reputation: 46
  • View blog
  • Posts: 454
  • Joined: 22-December 08

Re: Insert Table into database and get row number

Posted 08 February 2010 - 07:59 PM

Well what you would have to do is basically treat your HTML table as XML and build a function that parses it looking for all values inside of Table.TR.TD. After that you just have to insert all the data.
Was This Post Helpful? 0
  • +
  • -

#5 Craig328  Icon User is offline

  • I make this look good
  • member icon

Reputation: 1926
  • View blog
  • Posts: 3,471
  • Joined: 13-January 08

Re: Insert Table into database and get row number

Posted 01 March 2010 - 12:25 PM

View Postmpryan73, on 06 February 2010 - 01:23 AM, said:

Sorry Craig I was not very clear. I have a html page with a table on it and I want to scrap it basicly and insert the data into a database.


You want to consume an HTML table and draw from it the information contained in the cells and save them to a database?

Yeah, what you'll want to do is either go to the trouble of building what amounts to a screenscrape function and then loop over the results of that and insert the gleaned data into a database table...

...or, if there isn't that much data, simply write the database insert statements by hand. The thing is, you could write the function to consume a table and spit out usable data on the backend but the write/test/fix cycle to build it so that it accurately runs at the end may be more trouble (read: "time and typing") than simply eyeballing the data on the screen and writing the SQL inserts manually.

Good luck with that.
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1