cloudy

Author Topic: Embed PHP into an HMTL webpage  (Read 2353 times)

0 Members and 1 Guest are viewing this topic.

Offline mth

  • Posts: 1,438
  • Baltimore, Maryland
    • Relay, Maryland Weather Source
Embed PHP into an HMTL webpage
« on: July 09, 2006, 12:35:35 PM »
Ok guys, I've used the search within this forum and think that this has never been discussed in detail.

How do I take these php pages that I have gotten to work (Thanks Carterlake / Tnet / Saratoga) :D
http://69.143.144.53/buoy-data.php
http://69.143.144.53/hazards.php
http://69.143.144.53/forecast.php

....and embed them with my html pages?  I see that Tom and Ken use a small window for the NOAA advisories that I assume will get bigger when an advisory/watch becomes available. I've had to use an Iframe and point it to my hazards page( http://69.143.144.53/wx5.html ).  I know this is wrong and when the text becomes larger than the frame can handle it will cut off...... :(

...Also, I see that people are taking just the "tonight" / "tomorrow" forecast icons and text and display them on their home pages.  How do you disassemble the forecast PHP and place just these two forecast images/text on your mainpages? #-o


I'm new to PHP and a little insight will probably help me out tremendously. 

Thanks in Advance,
Michael
Michael Holden
Relay, Maryland Weather Station
http://www.relayweather.com


Online JaxWeather

  • Bob
  • Global Moderator
  • Posts: 11,235
  • WML Station: WD00007
  • Jacksonville, Fl. USA
    • JaxWeather.net
Re: Embed PHP into an HMTL webpage
« Reply #1 on: July 09, 2006, 12:58:50 PM »
Michael,

Why not change all of your web pages to use PHP extension and then you can inlude any thing you want with a simple PHP include...

Code: [Select]
<? include "buoy-data.php" ?>
My whole site is basically a bunch of includes, as you can use the PHP include to include any .html or .php file in a page...

-Bob

Offline saratogaWX

  • Posts: 4,577
  • Saratoga, CA, USA 37:16:28N, 122:01:23W - Elev: 374ft.
    • Saratoga Weather
Re: Embed PHP into an HMTL webpage
« Reply #2 on: July 09, 2006, 01:09:41 PM »
Michael:

Bob's right.. the easiest way is to change the page extension to be .php, then use the native PHP method ( include() ) to bring in the info you want to add.

The extension on the page name really determines what the webserver is going to do with the page when it's requested by the client browser.  If the type is '.htm' or '.html', that tells the webserver to 'just return the page, no processing is necessary'.  If the type is '.shtm' or '.shtml', the webserver will parse the page looking for Server Side Includes (SSI) variables, substitute for them, then return the page to the browser.  If the page type is '.php', the webserver sends the page to the PHP interpreter to process, and returns the result to the browser.

When you use an IFRAME to include a page, the webserver does nothing special, but the browser does the assembly by requesting a different page from that (or a different) webserver.  The downside of IFRAMES is what you'd cited.. if the page gotten by the IFRAME is bigger than the space allowed, it's cut off (or creates scroll bars if that parameter is enabled on the IFRAME tag).

In short.. best way is to rename the calling page extension to be .php and use
Code: [Select]
<?php include("pagename.php"); ?> where you want the content to appear in  your page.

Ken
Ken True
Saratoga Weather
CWOP: CW1792
WeatherUnderground: KCASARAT1
Free weather website PHP scripts and WD website AJAX templates

Offline mth

  • Posts: 1,438
  • Baltimore, Maryland
    • Relay, Maryland Weather Source
Re: Embed PHP into an HMTL webpage
« Reply #3 on: July 09, 2006, 02:16:07 PM »
Thanks for the quick response gents!

If I change my pages to be php, then how will WDisplay update them?
Michael Holden
Relay, Maryland Weather Station
http://www.relayweather.com


Online JaxWeather

  • Bob
  • Global Moderator
  • Posts: 11,235
  • WML Station: WD00007
  • Jacksonville, Fl. USA
    • JaxWeather.net
Re: Embed PHP into an HMTL webpage
« Reply #4 on: July 09, 2006, 02:27:25 PM »
Michael,

If you are using Internet File creation you can set the file name to be different when uploaded.  The way I do it is just let WD create the pages normally as .html files and then I built web pages with .php extensions that call each of the WD created pages...

-Bob

Offline mth

  • Posts: 1,438
  • Baltimore, Maryland
    • Relay, Maryland Weather Source
Re: Embed PHP into an HMTL webpage
« Reply #5 on: July 09, 2006, 02:42:47 PM »
Bob,

Where is WD do you accomplish this? 

Mike
Michael Holden
Relay, Maryland Weather Station
http://www.relayweather.com


Offline mth

  • Posts: 1,438
  • Baltimore, Maryland
    • Relay, Maryland Weather Source
Re: Embed PHP into an HMTL webpage
« Reply #6 on: July 09, 2006, 02:56:02 PM »
Michael,

If you are using Internet File creation you can set the file name to be different when uploaded.  The way I do it is just let WD create the pages normally as .html files and then I built web pages with .php extensions that call each of the WD created pages...

-Bob

Bob,

Are you saying that you let WD do its thing normally and then create a page (wx5.php) and have this page call the html page?  If so what do you mean by "call"?

Mike
Michael Holden
Relay, Maryland Weather Station
http://www.relayweather.com


Online JaxWeather

  • Bob
  • Global Moderator
  • Posts: 11,235
  • WML Station: WD00007
  • Jacksonville, Fl. USA
    • JaxWeather.net
Re: Embed PHP into an HMTL webpage
« Reply #7 on: July 09, 2006, 05:35:46 PM »
Hi again Mike,

Take this page:
http://jaxweather.net/Climate.php

That is a custom web file I created that uses the PHP include function to call:
http://jaxweather.net/WeatherImages/WD/climatedataout.html

So WD creates and uploads the normal climatedataout.html file and I simply include it in the page I want it in :)

-Bob

Offline HobbyTalk

  • Posts: 719
  • Kalamazoo, MI
    • Kalamazoo Weather
Re: Embed PHP into an HMTL webpage
« Reply #8 on: July 09, 2006, 07:57:48 PM »
You can also make an html page include other files using SSI (server side includes) as I do on my web pages. If you look at the main page http://www.hobbytalk.com/weather/index.html it includes pages http://www.hobbytalk.com/weather/wx.html and http://www.hobbytalk.com/weather/wx20.html

If you are on a server that runs Apache then the easiest way to do it is using the XBitHack. To do that just create an .htaccess file in the root of your weather directory and put the following in that file.

AddHandler server-parsed .html

 

cumulus