dmkc Posted May 4, 2010 Share Posted May 4, 2010 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 Link to comment https://forums.phpfreaks.com/topic/200670-displaying-url-from-mysql-db-in-an-iframe/ Share on other sites More sharing options...
oh_boy123 Posted May 4, 2010 Share Posted May 4, 2010 try changing that lines.. i think that was your problem.. if ($_GET['id']) { $id = $_GET['id']; $gethotel= @mysql_query ("SELECT * FROM yourtable WHERE id='$id' ") or die(mysql_error()); Link to comment https://forums.phpfreaks.com/topic/200670-displaying-url-from-mysql-db-in-an-iframe/#findComment-1053031 Share on other sites More sharing options...
oh_boy123 Posted May 4, 2010 Share Posted May 4, 2010 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>"; Link to comment https://forums.phpfreaks.com/topic/200670-displaying-url-from-mysql-db-in-an-iframe/#findComment-1053040 Share on other sites More sharing options...
dmkc Posted May 4, 2010 Author Share Posted May 4, 2010 thanks for the replies, using the echo you suggested, it causes a "Parse error: syntax error, unexpected $end" I think it's something to do with the syntax I used when trying to echo the url into the iframe..... Link to comment https://forums.phpfreaks.com/topic/200670-displaying-url-from-mysql-db-in-an-iframe/#findComment-1053052 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.