Is it possible?

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
tstimple
Forum Commoner
Posts: 53
Joined: Wed Jan 21, 2004 10:12 pm

Is it possible?

Post by tstimple »

Being new to PHP I was hoping someone could help me with this.

Is it possible to pass a variable to be part of a IFRAME src link

For Example...
I have a HTML page (not a form) that has dozens of links. These links each open seperate pages that each contain an IFRAME that, in-turn, loads some data from an external client.

The first page has many simple links like:

Code: Select all

<a href="search25951.htm"
This opens a page that includes an iframe that looks like:

Code: Select all

<iframe src="http://www.getauto.com/viewinventory.html?dealer_id=25951" scrolling="yes" name="results" id="results" width="810" height="625" marginwidth="0" marginheight="0" hspace="0" vspace="0" align="top" frameborder="0"></iframe>
The ONLY differnece in these many pages is the dealer_id number.
The problem is I have hundreds of these such links and I have been creating seperate "IFRAME" pages for each of these.

Would it be possible to write a single PHP page that could include an IFRAME and pass the dealer_id number as a variable to this page's IFRAME src?

I hope I am being clear on what I want to do...
If anyone could show me an example of how that would be done it would save me alot of work. Thanks...

--Tim
tstimple
Forum Commoner
Posts: 53
Joined: Wed Jan 21, 2004 10:12 pm

Can I do it like this....

Post by tstimple »

This is somthing what I had in mind...

Link:

Code: Select all

&lt;a href="search.php?dlrID=25291&gt;&lt;/a&gt;
and the php file:

Code: Select all

<?php
$dlrID = $_GET['dlrID']
<iframe src="http://www.getauto.com/viewinventory.html?dealer_id=[$dlrID]" scrolling="yes" name="results" id="results" width="810" height="625" marginwidth="0" marginheight="0" hspace="0" vspace="0" align="top" frameborder="0"></iframe>
?>
But I'm not sure if this will work or how to make the IFRAME show in PHP (or a mixture of PHP/HTML)

Sorry..I'm a newbie :?
User avatar
dull1554
Forum Regular
Posts: 680
Joined: Sat Nov 22, 2003 11:26 am
Location: 42:21:35.359N, 76:02:20.688W

Post by dull1554 »

if you pass the dealer id to the get array you would have to make your iframe like this

Code: Select all

<?php
$dlrID = $_GET['dlrID']
echo "<iframe src='http://www.getauto.com/viewinventory.html?dealer_id='".$dlrID." scrolling='yes' name='results' id='results' width='810' height='625' marginwidth='0' marginheight='0' hspace='0' vspace='0' align='top' frameborder='0'></iframe>
?>
User avatar
dull1554
Forum Regular
Posts: 680
Joined: Sat Nov 22, 2003 11:26 am
Location: 42:21:35.359N, 76:02:20.688W

Post by dull1554 »

sorry,

Code: Select all

<?php
$dlrID = $_GET['dlrID']
echo "<iframe src='http://www.getauto.com/viewinventory.html?dealer_id='".$dlrID." scrolling='yes' name='results' id='results' width='810' height='625' marginwidth='0' marginheight='0' hspace='0' vspace='0' align='top' frameborder='0'></iframe>";
?>
Illusionist
Forum Regular
Posts: 903
Joined: Mon Jan 12, 2004 9:32 pm

Post by Illusionist »

would the same work if you did:

Code: Select all

<?php 
$dlrID = $_GET['dlrID'] 
?>

<iframe src="http://www.getauto.com/viewinventory.html?dealer_id=$dlrID" scrolling="yes" name="results" id="results" width="810" height="625" marginwidth="0" marginheight="0" hspace="0" vspace="0" align="top" frameborder="0"></iframe>
User avatar
dull1554
Forum Regular
Posts: 680
Joined: Sat Nov 22, 2003 11:26 am
Location: 42:21:35.359N, 76:02:20.688W

Post by dull1554 »

you would have to do this

Code: Select all

<?php
$dlrID = $_GET['dlrID']
?>

<iframe src="http://www.getauto.com/viewinventory.html?dealer_id=<?php echo $dlrID; ?>" scrolling="yes" name="results" id="results" width="810" height="625" marginwidth="0" marginheight="0" hspace="0" vspace="0" align="top" frameborder="0"></iframe>
hope that helps
tstimple
Forum Commoner
Posts: 53
Joined: Wed Jan 21, 2004 10:12 pm

That's just what I figured

Post by tstimple »

dull1554,
Thanks
Beleive it or not I had just tried exactly what you suggested (by trial and error)
It works perfect :D
Thanks again,
--Tim
User avatar
dull1554
Forum Regular
Posts: 680
Joined: Sat Nov 22, 2003 11:26 am
Location: 42:21:35.359N, 76:02:20.688W

Post by dull1554 »

no problem thats what were here for
Post Reply