Jump to content

Insert image names into mysql - list pulled from remote server (cURL)


visda04

Recommended Posts

I have successfully pulled a list of image names from a remote web server:

See my list here:

http://www.katy2go.com/weather/loadoverlays.php

(if you view the source you can see where I think I am headed with this...)

 

I would like to insert the three bits of information, for each image, into my mysql database. With my limited knowledge mysql skills I am having great difficulties with the INSERT or UPDATE query to make this happen. Can some one offer assistance...

 

 

<?php
ini_set('display_errors', 1);

// Make a MySQL Connection
$link = mysql_connect('', '', '') ;
mysql_select_db("") or die(mysql_error());
if (!$link) {
    die('Could not connect: ' . mysql_error());
}
echo 'Connected successfully';


$html = file_get_contents('http://www.srh.noaa.gov/ridge/RadarImg/NCR/HGX/');

    /*** a new dom object ***/
    $dom = new domDocument;

    /*** load the html into the object ***/
    $dom->loadHTML($html);

    /*** discard white space ***/
    $dom->preserveWhiteSpace = false;

    /*** the table by its tag name ***/
    $tables = $dom->getElementsByTagName('table');

    /*** get all rows from the table ***/
    $rows = $tables->item(0)->getElementsByTagName('tr');

    /*** loop over the table rows ***/
    foreach ($rows as $row)
    {
        /*** get each column by tag name ***/
        $cols = $row->getElementsByTagName('td');

/*** echo the values ***/
$icon=$cols->item(0)->nodeValue;
     //   echo $cols->item(0)->nodeValue.'<br />';
  echo $icon.'<br />';
$image=$cols->item(1)->nodeValue;
    //    echo $cols->item(1)->nodeValue.'<br />';
  echo $image.'<br />';
$when=$cols->item(2)->nodeValue;
    //    echo $cols->item(2)->nodeValue.'<br />';
  echo $when.'<br />';
$howbig=$cols->item(3)->nodeValue;
    //    echo $cols->item(3)->nodeValue;
  echo $howbig.'<br />';
        echo '<hr />'; 


}
?> 

 

Thanks,

Robert

Link to comment
Share on other sites

  • 2 weeks later...
This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.