visda04 Posted September 21, 2009 Share Posted September 21, 2009 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 https://forums.phpfreaks.com/topic/175025-insert-image-names-into-mysql-list-pulled-from-remote-server-curl/ Share on other sites More sharing options...
fenway Posted October 2, 2009 Share Posted October 2, 2009 I don't see any SQL statements there. Link to comment https://forums.phpfreaks.com/topic/175025-insert-image-names-into-mysql-list-pulled-from-remote-server-curl/#findComment-929123 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.