EddieRock Posted July 6, 2008 Share Posted July 6, 2008 Newbie here again... I'm having difficulty trying to think how to explain this so please bare with me... I'm looking to replace a repeatable url in my website with a php file. This link is a Amazon product link that is in an iframe. All of the code/url in the iframe is the same except for the Amazon ASIN (Product Number) What I want to do is replace the entire "repeatable url" with a php file with and have this code after it ?ASIN= to insert the Amzaon ASIN in the link. After the = sign, I would put the Amazon ASIN. Then when the page loads, the php file will be replaced with the repatable link with the ASIN in it. So, is there a way to replace something like this: <iframe src="http://rcm.amazon.com/e/cm?t=nikondigitalcamera-20&o=1&p=8&l=as1&asins=B000HJPK0Y&fc1=000000&IS2=1<1=_blank&lc1=0000FF&bc1=000000&bg1=FFFFFF&f=ifr" style="width:120px;height:240px;" scrolling="No" marginwidth="0" marginheight="0" frameborder="0"></iframe> with something like this: <iframe src="product_link.php?ASIN=B000HJPK0Y" width="120" height="240" scrolling="no" marginwidth="0" marginheight="0" frameborder="0"></iframe> Please note: the B000HJPK0Y in the code above is one of MANY Amazon products. I will be displaying many different products so I would like to have the product_link.php?ASIN= to insert the Amazon product code. Don't forget, I'm a newbie and I really thank you for your help. Can someone reply back with the code I would put in the product_link.php file? thanks a million! EddieRock ~newbie Link to comment https://forums.phpfreaks.com/topic/113438-php-file-to-call-a-url-and-have-the-url-in-an-iframe/ Share on other sites More sharing options...
fanfavorite Posted July 6, 2008 Share Posted July 6, 2008 This should be in the REGEX forum. First you need to figure out what stays the same in the amazon URL. $data = '<iframe src="http://rcm.amazon.com/e/cm?t=nikondigitalcamera-20&o=1&p=8&l=as1&asins=B000HJPK0Y&fc1=000000&IS2=1<1=_blank&lc1=0000FF&bc1=000000&bg1=FFFFFF&f=ifr" style="width:120px;height:240px;" scrolling="No" marginwidth="0" marginheight="0" frameborder="0"></iframe>'; preg_match_all("/asins=(.*)&fc1/Uis",$data, $matches); echo '<iframe src="product_link.php?ASIN='.$matches[1][0].'" width="120" height="240" scrolling="no" marginwidth="0" marginheight="0" frameborder="0"></iframe>'; The above will take out the asin from the URL and put it into your iframe. Link to comment https://forums.phpfreaks.com/topic/113438-php-file-to-call-a-url-and-have-the-url-in-an-iframe/#findComment-582948 Share on other sites More sharing options...
EddieRock Posted July 6, 2008 Author Share Posted July 6, 2008 I tried it and didn't work. Here is what I have in my main file that loads in the browser: <iframe src="product_link.php?ASIN=B00005LE73" width="120" height="240" scrolling="no" marginwidth="0" marginheight="0" frameborder="0"></iframe> Here is the code in product_link.php: <?php $data = '<iframe src="http://rcm.amazon.com/e/cm?t=nikondigitalcamera-20&o=1&p=8&l=as1&asins=B000HJPK0Y&fc1=000000&IS2=1<1=_blank&lc1=0000FF&bc1=000000&bg1=FFFFFF&f=ifr" style="width:120px;height:240px;" scrolling="No" marginwidth="0" marginheight="0" frameborder="0"></iframe>'; preg_match_all("/asins=(.*)&fc1/Uis",$data, $matches); echo '<iframe src="product_link.php?ASIN='.$matches[1][0].'" width="120" height="240" scrolling="no" marginwidth="0" marginheight="0" frameborder="0"></iframe>'; ?> and nothing happens. I think the code in the main page may be wrong. Any suggestions? EddieRock ~newbie Link to comment https://forums.phpfreaks.com/topic/113438-php-file-to-call-a-url-and-have-the-url-in-an-iframe/#findComment-583044 Share on other sites More sharing options...
fanfavorite Posted July 15, 2008 Share Posted July 15, 2008 Do a print_r(matches); after and see what is displayed. If there is nothing, then it found nothing. If there is something, then it may just be the wrong array portion that you are grabbing (matches[1][0]). Link to comment https://forums.phpfreaks.com/topic/113438-php-file-to-call-a-url-and-have-the-url-in-an-iframe/#findComment-590125 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.