iFrame with database field value

ChrisTERiS
ChrisTERiS used Ask the Experts™
on
Hello,

I know how to add an iFrame which will contains a file with "src" tag, but what if I want to show in the iframe a variable which holds the value of a database field?

Thank you
Comment
Watch Question

Do more with

Expert Office
EXPERT OFFICE® is a registered trademark of EXPERTS EXCHANGE®

Author

Commented:
Points increased
stu215Systems Analyst/Project Manager/Programmer

Commented:
You would put the variable and any content on the source page you referenced in the "src=" part of the iFrame tag.

Author

Commented:
Sorry, didn't got your meaning. Let's try with a real example. I've a variable $tos which holds a very long text (a Terms od Use). What I've to do? src="'.$tos.'" dosen't works.

Success in ‘20 With a Profitable Pricing Strategy

Do you wonder if your IT business is truly profitable or if you should raise your prices? Learn how to calculate your overhead burden using our free interactive tool and use it to determine the right price for your IT services. Start calculating Now!

stu215Systems Analyst/Project Manager/Programmer

Commented:
ex: Page1

<iframe src="yourPage.php" width="500" height="400">
</iframe>


----------------------------------------------------------
page2 :: yourPage.php


<?php
    phpinfo();
?>

stu215Systems Analyst/Project Manager/Programmer

Commented:
using your variable you would put the following in page 2 "yourPage.php" ::



<?php
 echo "$tos"
?>
stu215Systems Analyst/Project Manager/Programmer

Commented:
you would also need to include your database query in "yourPage.php"

Systems Analyst/Project Manager/Programmer
Commented:
Sorry, just waking up here, was thinking database but meant to say define your variable in that page.

<?php
$tos="<your terms of service go here>"

 echo "$tos"
?>
stu215Systems Analyst/Project Manager/Programmer

Commented:
I have attached two test files to here that you can use as examples and change.
page1.html
yourPage.php

Author

Commented:
So, it was only by trick. I thought to have a file working as your example, or even to create at run time a file with the content using fopen(), but I was hoping that maybe should be a special tag of iframe to do all the job.
stu215Systems Analyst/Project Manager/Programmer

Commented:
If you have a <form> on the first page you could also pass the variable to the second page and display it without using php.

<form name='form1' action='yourPage.html' method='post' target='<the name of your iframe goes here>'>
<input type='hidden' name='tos' value='my terms of service'>
</form>

Not quite sure why you'd want to do that with something like TOS which i imagine are static?
( Would just be simpler to have an html page containing the TOS load in the iframe if thats what your trying to do )

Author

Commented:
You're right, but I'm using to deliver easy to use scripts. So, all legal letters (TOS, Privacy etc etc), are creating in the admincp using a HTML editor, to be easily editable. Otherwise the end user must have even a small knowledge of using text editors and a bit HTML for bold letters, different font size etc.

In any case thank you.

Do more with

Expert Office
Submit tech questions to Ask the Experts™ at any time to receive solutions, advice, and new ideas from leading industry professionals.

Start 7-Day Free Trial