Jump to content

Retrieve HTML from mysql database


alexsmith2709

Recommended Posts

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

Link to comment
Share on other sites

$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

 

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.