Hello anyone. Thanks for the help in advance. Here is the problem. I am taking xml feed with 10 different rows <offer>:
The php code is:Code:<offers> <offer> <id></id> <url></url> <amount></amount> <price>0.</price> <seller><id></id><name></name></seller> </offer> <offer> <id></id> <url></url> <amount></amount> <price>0.</price> <seller><id></id><name></name></seller> </offer> . . . <offer> <id></id> <url></url> <amount></amount> <price>0.</price> <seller><id></id><name></name></seller> </offer> <offer>
This result is so only the first offer is inserted into the MySQL database. How can I make so all 10 offers to be inserted?Code:$xml = simplexml_load_file("URL TO XML FEED"); $seller = $xml->{'offer'}->{'seller'}->{'name'}; $sellerid = $xml->{'offer'}->{'seller'}->{'id'}; $amount = $xml->{'offer'}->{'amount'}; $price = $xml->{'offer'}->{'price'}; $url = $xml->{'offer'}->{'url'}; $flag = '/images/flags/'.$row['desig'].'.png'; $flag = strtolower($flag); $sql = ("INSERT INTO market (id, country, flag, industry, quality, seller, sellerid, amount, price, link) VALUES ('$id', '$name1', '$flag', '$name2', '$name3', '$seller', '$sellerid', '$amount', '$price', '$url')") or die('<b>Data Insert Error:</b> ' . mysql_error()); if (!mysql_query($sql,$con1)) { die('Error: ' . mysql_error()); }
Any help much appreciated.


Reply With Quote

Bookmarks