alexsmith2709 Posted December 29, 2011 Share Posted December 29, 2011 Hi, Im trying to retrieve HTML from a mysql database but nothing i've tried seems to work. The HTML im trying to retrieve is an iframe with a link and styles (code from amazon associates). Im trying to display links to specific products on amazon from the product page on my site. All data about the product is retrieved from the database so i have code to select the amazon link row in my database table but i cant get it to display. It says the html isnt a string so i cant echo it, fair enough. I have tried using the following code: $get_buylink_sql = "SELECT mobo_buylink FROM mobo WHERE mobo_id = $mobo_id"; $get_buylink_res = mysqli_query($mysqli, $get_buylink_sql) or die(mysqli_error($mysqli)); while ($buylink = mysqli_fetch_array($get_buylink_res)) { echo"<iframe src=\"".$buylink."\" style=\"width:120px;height:240px;\" scrolling=\"no\" marginwidth=\"0\" marginheight=\"0\" frameborder=\"0\"></iframe>"; } mysqli_free_result($get_buylink_res); mysqli_close($mysqli); I have also tried putting the whole iframe code in the database which didnt work either. The mobo_id variable works fine for retrieving the rest of the data and i need to get the amazon link from the same record. I hope i've put this in a way you can understand, but if not i'll try and explain better and give you a link to my site if needed. Thanks, Alex Quote Link to comment https://forums.phpfreaks.com/topic/254018-retrieve-html-from-mysql-database/ Share on other sites More sharing options...
PFMaBiSmAd Posted December 29, 2011 Share Posted December 29, 2011 $buylink is an array (which is why mysqli_fetch_array was named that.) You would need to reference the correct index of that array - $buylink['mobo_buylink'] There are examples of all the basic php statement usage in the php.net documentation - http://us3.php.net/manual/en/mysqli-result.fetch-array.php Quote Link to comment https://forums.phpfreaks.com/topic/254018-retrieve-html-from-mysql-database/#findComment-1302174 Share on other sites More sharing options...
alexsmith2709 Posted December 29, 2011 Author Share Posted December 29, 2011 Thanks very much, my silly mistake! All seems to work great now Quote Link to comment https://forums.phpfreaks.com/topic/254018-retrieve-html-from-mysql-database/#findComment-1302182 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.