msd_luke
04-07-2009, 08:44 AM
Hi All,
ok i am trying to set up a price comparision feature on my site, i have several product feeds to use but i have a few problems.
1/ some of the product feeds contain too many products and i get an out of memory error. is there a way around this? my php limit is 24mb i think.
2/ im not sure how to insert all the required data into the db table so far i have
$xml=("http://ax.itunes.apple.com/WebObjects/MZStoreServices.woa/ws/RSS/topsongs/sf=143444/limit=10/explicit=true/xml?partnerId=2003&TD_PARAM=http://clkuk.tradedoubler.com/click?p=23708&a=1515427&url=");
$xmlDoc = new DOMDocument();
$xmlDoc->load($xml);
for ($i = 0; $i < 10; $i++) {
//get elements from "<channel>"
$channel=$xmlDoc->getElementsByTagName('entry')->item($i);
$channel_title =
mysql_real_escape_string($channel->getElementsByTagName('title')->item(0)->childNodes->item(0)->nodeValue);
$channel_image =
mysql_real_escape_string(str_replace("30x30-50","100x100-75",$channel->getElementsByTagName('image')->item(0)->childNodes->item(0)->nodeValue));
$channel_link =
mysql_real_escape_string($channel->getElementsByTagName('id')->item(0)->childNodes->item(0)->nodeValue);
$channel_album =
mysql_real_escape_string($channel->getElementsByTagName('name')->item(0)->childNodes->item(0)->nodeValue);
$channel_artist =
mysql_real_escape_string($channel->getElementsByTagName('artist')->item(0)->childNodes->item(0)->nodeValue);
$channel_cost =
mysql_real_escape_string($channel->getElementsByTagName('price')->item(0)->childNodes->item(0)->nodeValue);
//output elements from "<channel>"
$sql = "INSERT INTO product_database (pID, store, storeLink, productTitle, productLink, productIMG, description, price) VALUES ($i, 'itunes', '$channel_link', '$channel_artist - $channel_album', '$channel_link', '$channel_image', 'description here','$channel_cost')";
$query = mysql_query($sql);
echo ("<a href='$channel_link'>".$channel_title."</a>");
echo("<br />");
echo $channel_album;
echo("<br />");
echo $channel_artist;
echo("<br />");
echo $channel_cost;
echo("<br />");
echo ("<img src='$channel_image'>");
echo("<br />");
}
which work if i know the number of products but i dont know how to code the above for an unknown number of products
3/ what is the best way to do this?
any help would be greatly appreciated
Thanks
Luke
ok i am trying to set up a price comparision feature on my site, i have several product feeds to use but i have a few problems.
1/ some of the product feeds contain too many products and i get an out of memory error. is there a way around this? my php limit is 24mb i think.
2/ im not sure how to insert all the required data into the db table so far i have
$xml=("http://ax.itunes.apple.com/WebObjects/MZStoreServices.woa/ws/RSS/topsongs/sf=143444/limit=10/explicit=true/xml?partnerId=2003&TD_PARAM=http://clkuk.tradedoubler.com/click?p=23708&a=1515427&url=");
$xmlDoc = new DOMDocument();
$xmlDoc->load($xml);
for ($i = 0; $i < 10; $i++) {
//get elements from "<channel>"
$channel=$xmlDoc->getElementsByTagName('entry')->item($i);
$channel_title =
mysql_real_escape_string($channel->getElementsByTagName('title')->item(0)->childNodes->item(0)->nodeValue);
$channel_image =
mysql_real_escape_string(str_replace("30x30-50","100x100-75",$channel->getElementsByTagName('image')->item(0)->childNodes->item(0)->nodeValue));
$channel_link =
mysql_real_escape_string($channel->getElementsByTagName('id')->item(0)->childNodes->item(0)->nodeValue);
$channel_album =
mysql_real_escape_string($channel->getElementsByTagName('name')->item(0)->childNodes->item(0)->nodeValue);
$channel_artist =
mysql_real_escape_string($channel->getElementsByTagName('artist')->item(0)->childNodes->item(0)->nodeValue);
$channel_cost =
mysql_real_escape_string($channel->getElementsByTagName('price')->item(0)->childNodes->item(0)->nodeValue);
//output elements from "<channel>"
$sql = "INSERT INTO product_database (pID, store, storeLink, productTitle, productLink, productIMG, description, price) VALUES ($i, 'itunes', '$channel_link', '$channel_artist - $channel_album', '$channel_link', '$channel_image', 'description here','$channel_cost')";
$query = mysql_query($sql);
echo ("<a href='$channel_link'>".$channel_title."</a>");
echo("<br />");
echo $channel_album;
echo("<br />");
echo $channel_artist;
echo("<br />");
echo $channel_cost;
echo("<br />");
echo ("<img src='$channel_image'>");
echo("<br />");
}
which work if i know the number of products but i dont know how to code the above for an unknown number of products
3/ what is the best way to do this?
any help would be greatly appreciated
Thanks
Luke