jeffpim Posted July 9, 2008 Share Posted July 9, 2008 New to PHP... I think there is a simple answer to this... I have a page with this simple link code: <a href="details.php?id=847288">view details</a> I want to be able to grab the id # and place in a new HREF within a SmartFrame on the 'details.php' page. I currently have this code at the top of 'details.php'... <?php $id = $_GET['id']; ?> My code for the SmartFrame is... <iframe name="smart_frame" width="740" height="950" marginwidth="1" marginheight="1" src="http://www.riliving.com/SmartFrames/sfdetails.asp?MLSid=$id"> I can not get $id to display the passed variable of 847288 - I just get a blank SmartFrame. When I hard code like below... it works correctly. How can I get $id to display 847288 <iframe name="smart_frame" width="740" height="950" marginwidth="1" marginheight="1" src="http://www.riliving.com/SmartFrames/sfdetails.asp?MLSid=847288"> Link to comment https://forums.phpfreaks.com/topic/113948-passed-variables-in-hrefs/ Share on other sites More sharing options...
revraz Posted July 9, 2008 Share Posted July 9, 2008 Are you starting PHP and echoing the line? Or maybe something like <iframe name="smart_frame" width="740" height="950" marginwidth="1" marginheight="1" src="http://www.riliving.com/SmartFrames/sfdetails.asp?MLSid=<?php echo $id ?>"> I don't use iframes, so I'm just tossing out a idea. Link to comment https://forums.phpfreaks.com/topic/113948-passed-variables-in-hrefs/#findComment-585610 Share on other sites More sharing options...
adam84 Posted July 9, 2008 Share Posted July 9, 2008 Since that variable $id is a php variable, you can use it when its between the php '<?' '?>' tags. If you try and use it outside of the php tags, then I think you will just get the actually '$id' being passed instead of the '847288' Link to comment https://forums.phpfreaks.com/topic/113948-passed-variables-in-hrefs/#findComment-585625 Share on other sites More sharing options...
jeffpim Posted July 10, 2008 Author Share Posted July 10, 2008 <?php echo $id ?> worked! Thanks! Link to comment https://forums.phpfreaks.com/topic/113948-passed-variables-in-hrefs/#findComment-586374 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.