Hi All,

I am new to Drupal and to web development in general. So it can easily happen that my question doesn't make much sense...

I'd like to include external data in my site. For example something similar to these headlines.

<IFRAME SRC="http://www.tiraspoltimes.com/headlines.php" width=220 height=280 marginwidth=0 marginheight=0 hspace=0 vspace=0 frameborder=0 scrolling=no></IFRAME>

When I create a new page or a new block with this code and specify FULL HTML it works fine.

But I'd like to introduce variables into my code. In this case it could be the dimensions of the window: $width and $height for example.

When I tried to do it with PHP, including the code between PHP tags, I didn't get any result.... obviously I'm doing something wrong. Maybe the whole concept of iframe is different and not meant to be used like this. I do not know...

Can anywone please help me out here.

Thanks a lot!

Alvo

Comments

mounte’s picture

how exactly did your php-page look like?
What is your goal with this, what do you want to accomplish?
If your goal just is to get the data from http://www.tiraspoltimes.com/headlines.php you could get them using php. And then print or echo out the content.

alvoe’s picture

Hi Mounte,

Thanks for your reply.

My final aim is actually not related to those news I've just thought about starting with something simpler.
What I really want is to use the financial market data from http://www.dukascopy.com/swiss/english/data_feed/webproducts/charts/
The code they provide:

<iframe name=DC src=http://freeserv.dukascopy.com/chart/?ql=1,2,3,4&interval=60&points_number=50&view_type=candle&width=500&height=300&osc_type=-1&osc_height=100&p1=2&p2=3&p3=7&c=&rfi=false&show_labels=false&show_border=false width=500 height=300 border=0 frameborder=0 marginwidth=0 marginheight=0 scrolling=no></iframe>

In this the 1,2,3,4 constants determine what data you can actually display in the chart. My aim would be to control those variables. For example from a drop down menu. OK.... I'm very far from that yet... since my knowledge of PHP is zero.... but this is the aim anyway.

My PHP code was very simple and probably very wrong. I have simple placed the provided codes between the PHP tags and tried to define variables and use those variable names inside the iframe tag. I will put it here to shock everybody.

<?php
$width
=250;
$height=250;
<
IFRAME SRC="http://www.tiraspoltimes.com/headlines.php" width=$width height=$height marginwidth=0 marginheight=0 hspace=0 vspace=0 frameborder=0 scrolling=no></IFRAME>;
?>

Thanks!

Alvo

mounte’s picture

To be able to actually see the output from the page you would like you have to print it from the php script.
Thus

<?php
$width
=250;
$height=250;

print(

'<IFRAME SRC="http://www.tiraspoltimes.com/headlines.php" width=' . $width . ' height=' . $height . ' marginwidth=0 marginheight=0 hspace=0 vspace=0 frameborder=0 scrolling=no></IFRAME>');
?>

So you see the little change right ...
We print a HTML-string from PHP by using the function print.
The string is built using the ' (single quote) which lets us use " (double quotes) inside the string without escaping them (read from php.net about escaping) we concatenate the string using the . (dot) operator so: 'string 1 ' . 'and' . ' string 2' results in 'string 1 and string 2'

alvoe’s picture

I guess I'd better start learning PHP basics... I just wanted a quick start with my problem and I've thought that it was more related to Drupal itself.

Thanks for your quick help!

Alvo

samstr’s picture

test