Jump to content

displaying url from mysql db in an iframe


dmkc

Recommended Posts

Hi again everyone,

 

Ok, what I want to do is display a url that's stored in my database within an iframe when the specific record is selected.

 

The code I had to display the record correctly is:

 

<?php
$conn = mysql_connect(HOST,USER,PASS);
$db = mysql_select_db("***") or die( "Unable to select database");
if(isset($_GET["id"]))
{
$gethotel= mysql_query ("SELECT * FROM "***" WHERE id='$_GET[id]'") or die(mysql_error());
$count = mysql_num_rows($gethotel);
     if($count == 1)
     {
     $row = mysql_fetch_assoc($gethotel);
     {
     $hotel= $row['link_text'];
     $address = $row['address'];
     $telephone= $row['telephone'];
 $url= $row['telephone'];
       echo "<strong> $hotel </strong><br /> $address <br /> Telephone: $telephone <br />";
     }
     }
elseif($count==0)
{
echo "There is no hotel with that name found!";
}
}
else
{
echo "There is no hotel found!";
}
?>

 

And then I was trying to pull the result from the "url" field in the database and display it using the following:

 

		<?php
$conn = mysql_connect(HOST,USER,PASS);
$db = mysql_select_db("****") or die( "Unable to select database");
if(isset($_GET["id"]))
{
$gethotel= mysql_query ("SELECT * FROM "****" WHERE id='$_GET[id]'") or die(mysql_error());
$count = mysql_num_rows($gethotel);
     if($count == 1)
     {
     $row = mysql_fetch_assoc($gethotel);
     {
 $url= $row['url'];
{
echo  "<iframe src=$url style="background: #fff;" frameborder="0" height="450" scrolling="auto" width="100%"></iframe>";
		</div>
}
?>

 

Although that doesn't work - does anyone know where I'm going wrong?

 

thanks :)

and this one too... check it

 

echo "<iframe src=$url style="background: #fff;" frameborder="0" height="450" scrolling="auto" width="100%"></iframe>"; </div>

 

remove the </div> in inside your <? ?> and this one too looks like a buggy one

<iframe src=$url without the "

 

maybe it should be

 

echo "<iframe src=\"$url\" style=\"background: #fff;\" frameborder=\"0\" height=\"450\" scrolling=\"auto\" width=\"100%\"></iframe>";

 

 

Archived

This topic is now archived and is closed to further replies.

×
×
  • 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.