Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Posting third party database in an iFrame

Status
Not open for further replies.

Kefer

Technical User
Oct 16, 2003
9
US
What i am trying to make happen is When an Item in the database is called upon through a link, I would like for the Item to show up in a designated area "iframe" in a single HTML page. That making the html page the only page that would be called every time an Item is diplayed and the Item would appear in the same place on the page every time. Is php the way to go and if so how would it be done. Any help would be great, Thank you in advance.
 
PHP is one way to do it.

Put the items from the database on the page as links with GET-method accompanying input:

<a href="yourscript.php?item=<some_identifier">Item from database</a>

The script then looks in $_GET['item'] to see what information to fetch and display.

Want the best answers? Ask the best questions!

TANSTAAFL!!
 
thank you for replying, What code do I put in the iframe for it to call it up. <iframe src="" width="580" height="525"></iframe>
I am sorry but I am new to this php code. Thanks
 
You would use whatever code necessary for PHP to output the HTML to populate the IFRAME. Generally, an IFRAME uses its "src" attribute to define a source to display data.

I'm thinking you'll need two PHP scripts working in conjunction:

overview.php will output the database links and by default a blank iframe (the "src" attribute of the iframe points to an HTML page that is blank). Each link will point back to the script itself with the GET-method input I described above. When the script finds that GET-method input, it reproduces the page, but with the "src" attribute of the iframe pointing to your second script. Something of the form:

<iframe src="detail.php?item=<item number matching previous link click></iframe>

The detail.php script will produce an HTML page from the database with more information about the item.


Want the best answers? Ask the best questions!

TANSTAAFL!!
 
I have just one question. Is it not possible to have overview.php output database links as such:

<a href="detail.php?item=<item from database>" target="myIframe">Item <item from database></a>

and then have an iframe on the overview.php that looks like this:

<iframe src="" name="myIframe" ...></iframe>

Looks like a much simpler solution to me.
 
The reason I'm asking is that according to my testing with Opera and IE, you can't display info in an iframe by placing text between the iframe's opening and closing tags.

This means that two scripts at once must act in concert to get the information into an iframe.

You could use tables in overview.php to put all the data on the page using one script.

Want the best answers? Ask the best questions!

TANSTAAFL!!
 
target in the main page link states that link is opened in an iframe called "myIframe". Everytime a link is clicked, <iframe name="myIframe"> updates its contents by the value in href="" of the link. It is the normal iframe working mechanism.
 
But then, won't the entire output of overview.php be in the iframe?

Even with that method, you'll still need two scripts, overview.php and detail.php.

Want the best answers? Ask the best questions!

TANSTAAFL!!
 
Of course two scripts are still needed. I never said they weren't. But updating entire page and changing the iframe src attribute as opposed to just updating the iframe (throught target attribute) sounds overkill to me. Overview.php would still look like this:
Code:
<?php

// connect to database and fetch records
...
// display links with database identifiers
...
// display iframe with no source
...
?>
While detail.php would be the same as before:
Code:
<?php

// grab identifier from $_GET array
...
// connect to database and fetch the record that matches identifier
...
// display relevant data
...
?>
 
Another way is using CSS instead iframe... you can put the info of the item inside <div>s and this div could have a fixed position, hight and width and have the "overflow" attribute in "scroll". So, everytime you click in a item, populate the info inside the divs.

Cheers.
 
Vragabond,thanks for your input the way you are explaining sound like the way I would need to go. Question #1 Does the "MyIframe" need to be a seperate file all by its self? because the way I have it now is the Iframe is in the middle of a page called tickets.php . Question #2 Does the Page that the links are on that leads to the "tickets.php" with the IFrame in which the data will show up on, need to be saved as a php? Right now I have it as a html.
Thank you all for your help
 
Ok, first of all, iframe works just like any other frame. That means that any page with an iframe needs to have two documents: a frameset and a frame. With iframe, the frameset can contain normal information. So yes, you will still need two pages:

On the first page, you will define your iframe:

<iframe src="" width="580" height="525" name="myIframe"></iframe>

The src attribute tells which page to load in the iframe when the page holding the iframe opens. If blank, nothing is displayed. By adding target to the links you tell them where to open. In our case, they will open in the frame called myIframe:

<a href="details.php?item=1" target="myIframe">Link 1</a>

details.php does not contain an iframe and is a normal page which opens inside the iframe on the first page.

Regarding the question about the page with links. The page that has the links will be the page that holds the iframe. And the page within the iframe will be the one that holds parsed information from the database the way sleipnir214 already explained. In that way, the page with the links does not have to be .php if it does not have any php code -- if you don't get the links from the database.

Here's a static html example of a working iframe:
Hope it helps.
 
Ok I understand and this would be great if that is how I had it set up, but it is not. First let me say I am selling tickets to a sports team just for the sake of explaining. Here is the set up, I have an html page that displayes information of the team and on that page I have a Picture of a ticket saying "click to buy tickets here" which is a hot spot "link". My desire is to have this link take you to a another Page named "tickets.php" in which as of right now has the IFrame in the center of the page. I would like for this page "tickets.php" to be the set templet for any tickets being displayed from the database in the IFrame located in the center of the page. So I would imagine that this page "tickets.php" would need to be called along with the ticket info from the database. Can this be done? and if I can go about it an eastier way your suggestion are appreciated. Thanks
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top