#1
  1. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Oct 2002
    Posts
    372
    Rep Power
    12

    Use JavaScript To Download Articles To Web Sites?


    I am wanting to write a script where people can copy and paste the script on their web sites and automatically download articles from my MySQL-enabled web site when someone visits their site.

    In other words, if I have a daily article that I enter into the MySQL database on my web site I want to have the article automatically appear on other people's web sites when a visitor visits their web sites.

    I have seen news web sites that let people copy and paste JavaScript on their individual web sites and the news articles automatically get updated daily. Can anyone provide pointers about how I might go about devising the code for that type of process?

    Thanking you in advance.

    Volitics
  2. #2
  3. Contributing User
    Devshed Intermediate (1500 - 1999 posts)

    Join Date
    Oct 2001
    Location
    New Zealand
    Posts
    1,774
    Rep Power
    24
    Write a PHP page that sits on your server and extracts article news from your mysql database and puts into a javascript array, eg:

    echo "newsHeadlines = new Array()\n";
    echo "newsLinks = new Array()\n";
    $x = 0;
    while ($news = mysql_fetch_array($query)) {
    echo "newsHeadlines[$x] = \"" . $news['HEADLINE'] . "\"\n";
    echo "newsLinks[$x++] = \"" . $news['LINK'] . "\"\n";
    }

    Then they can call that in their head section of their page:

    <script src='linktoyourpage.php'></script>

    Then once they have the array of headlines/links (and descriptions if need be), they can use javascript to arrange that however they like.
  4. #3
  5. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Oct 2002
    Posts
    372
    Rep Power
    12
    binky;

    Thank you for the help.

    Best Regards;

    Volitics

IMN logo majestic logo threadwatch logo seochat tools logo