How to convert a sql database of articles to html

Discussion in 'MySQL' started by iowadawg, Jun 2, 2006.

  1. #1
    I have a ton of articles in sql files only.
    How can I convert those articles in the sql files to html files?

    Thank you.
     
    iowadawg, Jun 2, 2006 IP
    mattmdesign likes this.
  2. websys

    websys Active Member

    Messages:
    841
    Likes Received:
    23
    Best Answers:
    0
    Trophy Points:
    78
    #2
    do you use any article management / cms software for your sites ?
     
    websys, Jun 4, 2006 IP
  3. iowadawg

    iowadawg Prominent Member

    Messages:
    10,918
    Likes Received:
    811
    Best Answers:
    0
    Trophy Points:
    380
    #3
    These huge databases of articles in sql form I purchased.
    Just need a way if there is a way to convert them to html.
    So I can grab the articles and put them where I want.
    Some articles I am sure I would not want on a site.
     
    iowadawg, Jun 4, 2006 IP
  4. danielbruzual

    danielbruzual Active Member

    Messages:
    906
    Likes Received:
    57
    Best Answers:
    0
    Trophy Points:
    70
    #4
    If you want to output the article to the user you could use a basic sql query ($row = mysql_fetch_array("SELECT * FROM articlestable WHERE id='the id of the article you want'");) and that would output the information of that article in an array ($row).

    If you want to literally get the information from the database and write it to an html document you have to use the fopen and fwrite functions (get the info with a sql query and then write it to the file).
     
    danielbruzual, Jun 4, 2006 IP
  5. iowadawg

    iowadawg Prominent Member

    Messages:
    10,918
    Likes Received:
    811
    Best Answers:
    0
    Trophy Points:
    380
    #5
    These files are in sql format, they are NOT on a site mysql, but on my computer.
     
    iowadawg, Jun 4, 2006 IP
  6. noppid

    noppid gunnin' for the quota

    Messages:
    4,246
    Likes Received:
    232
    Best Answers:
    0
    Trophy Points:
    135
    #6
    His suggestion is that you create a database and use the articles on demand by article id with a quick query.

    You would need one html page with php enabled. Grab the article ya need via mysql/php and echo the text in the proper place of your template.

    If you are trying to extract the data on your PC, you may need an editor or viewer that will strip tags and stuff that the mysql may have wrapped the text in.
     
    noppid, Jun 4, 2006 IP
  7. iowadawg

    iowadawg Prominent Member

    Messages:
    10,918
    Likes Received:
    811
    Best Answers:
    0
    Trophy Points:
    380
    #7
    If you are trying to extract the data on your PC, you may need an editor or viewer that will strip tags and stuff that the mysql may have wrapped the text in.

    That is what I need! The above, something to take these articles out of the sql format into html format.

    Loading them up to a database is not an option, as for some reason, each sql file is like 15mb and will not upload.
     
    iowadawg, Jun 4, 2006 IP
  8. noppid

    noppid gunnin' for the quota

    Messages:
    4,246
    Likes Received:
    232
    Best Answers:
    0
    Trophy Points:
    135
    #8
    I never needed an editor like that, so I don't have a recomendation.

    As for the upload, can ya FTP the file up and then access it to load it? I assume you are using PHPMyAdmin? I think ya can access a local file as well as the upload option I'm assuming failed on ya.
     
    noppid, Jun 4, 2006 IP
  9. kashem

    kashem Banned

    Messages:
    1,250
    Likes Received:
    76
    Best Answers:
    0
    Trophy Points:
    0
    #9
    to create a html file from a article in database file ,I think a small module of software can be built which will extract each article and create a html file.
     
    kashem, Jun 4, 2006 IP
  10. dddougal

    dddougal Well-Known Member

    Messages:
    676
    Likes Received:
    19
    Best Answers:
    0
    Trophy Points:
    108
    #10
    If you bought it then it will be as a mysql dump. The easiest way would be to upload it to your server and get your host to run the sql dump, it'l take them seconds they should do it no problem, then extract the data you want with a mysql query like the other guy said.

    If you cant possibly upload it then you might need to install mysql on your local machine and run the sql dump from there. Then do the same, run queries on it until you have the articles you want.

    There must be some software out there to extract all the data from a mysql dump.
     
    dddougal, Jun 9, 2006 IP
  11. edr

    edr Guest

    Messages:
    784
    Likes Received:
    15
    Best Answers:
    0
    Trophy Points:
    0
    #11
    I do most of my programming in classic ASP so there is certainly an equivalent method in PHP but basically:

    1) Write a query to grab your records from the MySQL db
    2) Open a file system object (this will become your HTML file)
    3) Write the recordset to a string including all the usual suspects (html, head, body, etc.)
    4) Write the string you have created to the file system object
    5) Save the file and close the object
    6) Go to the next record and Loop 2 thru 5 until finished

    For file naming you can use the title from the articles replacing spaces with dashes and maybe getting smart about filename length and/or occurrances of words like "and" "or" "if" etc so you keep just keywords.

    Hope that makes sense.

    I understand why you want to do this Iowadog - I have recipe pages I do the same thing with - such that the resultant call to the page does not involve a query to the DB - speeds up the page load considerably - and if the content will be static then why not do it this way?
     
    edr, Jun 10, 2006 IP
  12. iconv

    iconv Well-Known Member

    Messages:
    189
    Likes Received:
    3
    Best Answers:
    0
    Trophy Points:
    108
    #12
    The easiest solution I can think of would be to write a Perl script to read the sql file(s) and extract the articles, fixing the escape characters on the fly.
     
    iconv, Jun 28, 2006 IP
  13. adolix

    adolix Peon

    Messages:
    787
    Likes Received:
    32
    Best Answers:
    0
    Trophy Points:
    0
    #13
    iowadawg, it is much "healtyer" to keep your articles in a SQL database. in this way you will be able to modify, edit, view them much easier. i would suggest you to ask your webhosting company to help you. a couple of months ago, i had exactly the same problem :) i needed to import a database that was very big and phpmyadmin crashed because it did not finish loading the sql file in the set timeout. So I emailed them, they said will help me, I uploaded the SQL files to FTP, and they imported it for me.... you should try it.
     
    adolix, Jun 29, 2006 IP