View Full Version : Very Basic PHP Help..

12-02-2010, 02:26 AM
Hey, I have done this before, but I have not worked with HTML and PHP for a while now.. it has been over 3 years.. so I am out of touch..

Few things:

- I have one index.php page.. with the layout.. Whats the PHP code to display a .html page in the content space... and then have links to other .html pages to be displayed within the same index.php page with the layout.. so in the end, I would only have to update index.php page in order to make any changes to the website.. ?

- Also another question is more... HTML related.. you guys might know the answer to... I have a layout... and I am using Dreamweaver mainly.. I have layout in a table.. and then.. I centered the table.. so when a user opens the layout.. it is centered.. on the screen.. I am trying to create a cell on top of the layout table.. however... the cell is not centered according to the table.. so.. as the user changes the size of the window, the cell moves accordingly... so it is never fixed in one place according to the table and a layout.. Its an 'AP Div' .. is there any way to have that overlay the table and the layout.. have content in it and have it fixed into one location? Not sure how else to explain this.. have a table with multiple sections.. and I just need continuous content on top of those multiple section without making the table sections larger or smaller than their fixed size..

Thanks in advance for the help!

12-02-2010, 02:31 AM
Generally it's done like this

//Php coding

Hi welcome to my website. Todays date is <?php $date ?>

Here is a picture <img src="images/pic.jpg"><br><br>

12-02-2010, 02:37 AM
Hey, thanks for the reply.

I know how to put in a PHP code.. however, I needed to know how exactly to have another page (.html) be displayed within an index.php page. Code I used before... was something like:

<?php If(!$id || $id=="" || file_exists("$id") == false){$number = "10"; include("cutenews/show_news.php");} else {include("$id");}

I used that to display news (CuteNews) when a user visited index.php.. the news would be displayed by default.. and when you click links.. it would appear like: '?id=biography.html' .. is that how I would work this? I have removed that news system.. so now, I just simply need a page to be displayed... what changed would I have to make to that code? And have the '?id=biography.html' types of links also work without any problem.. ?

12-02-2010, 03:52 AM
You could just do that with HTML frames. I THINK this is what you are asking. So it would be something like this:


$destination_page = $_GET['id'];


<head><title>I rule</title></head>
Welcome to my website. Here is a frame:

<frame src="./<?php echo $destination_page; ?>">


I think what you want is something like that. The code $destination_page = $_GET['id'] stores the value of 'id' from the URL into $destination_page. The code <?php echo $destination_page; ?> prints it out into the HTML. I think my syntax for a HTML frame may be a little off but this should still help you get the idea of what to do. LMK if you still have questions. Cheers!

12-02-2010, 06:22 AM
a modern version of your code (to account for register globals etc) would be something like...

$file = 'show_news.php';
if(!empty($_GET['id']) && file_exists($path.basename($_GET['id']).'.php')){

12-02-2010, 11:21 AM
Oh, I see.. yeah I could do iFrames... but even in the past, I got the effect I wanted without the use of iFrames.. I just mainly used AP Divs and such.... only this time.. I am actually centering the entire layout, so it is difficult to find a solution with using AP divs as they just simply float around and are position according to the browser window rather than your webpage itself... Unless I position the entire website to right left of the screen... I won't be able to use AP divs effectively like I have in the past..

And thanks firepages, I will use that code and see how it works out. I will no long be using cutenews script.. it was just an example of what I have done in the past, however, I will be looking to get another script similar to it. Thanks a lot. I will use that code from now on.