#1
  1. Full Access
    Devshed Regular (2000 - 2499 posts)

    Join Date
    Jun 2000
    Location
    London, UK
    Posts
    2,019
    Rep Power
    17
    I am planning on migrating a load of names listings to a mySQL database (currently at http://www.building-trade.com/search.htm). The problem is, there are over 14,000 records to be added! I already have them saved in HTML format with each record occupying one table row and each field occupying one table cell. Is there any way to move all this data easily into a mySQL database? Currently the only way I see of doing it is by copying and pasting each of the fields out of the HTML page and into a form! This would take over 56 man hours: is there a simpler way????
  2. #2
  3. No Profile Picture
    Apprentice Deity
    Devshed Loyal (3000 - 3499 posts)

    Join Date
    Jul 1999
    Location
    Niagara Falls (On the wrong side of the gorge)
    Posts
    3,237
    Rep Power
    19
    You could use PHP to parse the HTML page to break out the components. You could use regex but the string functions should be enough. First read in the file to a variable using the fopen, etc. and place into a variable, call it $html.

    $table=explode('able>',$html);

    The above will result in a 3 element array (assuming 1 table on the page, if not just adjust accordingly) with the 0th element holding everything through <table>, the first element everything after <table> and through </t(able> and the last holding everything after the </table>, note that only the </t of </table> will remain after the split. Use substr() to remove that. Now explode on 'r>' (assuming you don't have any other html tags inside the table ending in 'r' besides <tr> or </tr>.) This will give you an array holding the table rows (which will become records) each ending in the </t of </tr>. Again remove the last 3 characters of each element (check out array_walk() function to help with that).

    Now set up a loop to split each element of that array exploding on 'd>', giving you another array which will hold the individual cells of the row your loop is currently on. Strip off the last three characters of each element ('</t' from </td> ) and then insert into the database. Once the loop completes all rows in the table will be transformed into database records with the individual cells of each row the corresponding fields of the record.
  4. #3
  5. Full Access
    Devshed Regular (2000 - 2499 posts)

    Join Date
    Jun 2000
    Location
    London, UK
    Posts
    2,019
    Rep Power
    17
    Thanks Rod, could you explain in more detail how to do this as I am very new to both PHP and mySQL
  6. #4
  7. No Profile Picture
    Apprentice Deity
    Devshed Loyal (3000 - 3499 posts)

    Join Date
    Jul 1999
    Location
    Niagara Falls (On the wrong side of the gorge)
    Posts
    3,237
    Rep Power
    19
    I sent you an email.

Similar Threads

  1. DEBUGGER in VC++ dumping memory leaks
    By kavi_s in forum C Programming
    Replies: 3
    Last Post: December 3rd, 2004, 03:00 PM
  2. Importing data from Excel into MySQL
    By Ben5082 in forum MySQL Help
    Replies: 3
    Last Post: December 19th, 2003, 09:23 AM
  3. <THEAD> not printing across multiple pages
    By allanmcc in forum HTML Programming
    Replies: 2
    Last Post: September 29th, 2003, 09:47 PM
  4. Replies: 0
    Last Post: August 13th, 2003, 04:18 AM
  5. importing data/outputing data mysql
    By punkisdead in forum MySQL Help
    Replies: 1
    Last Post: July 21st, 2003, 11:10 PM

IMN logo majestic logo threadwatch logo seochat tools logo