Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 6 of 6
  1. #1
    New Coder
    Join Date
    Aug 2009
    Posts
    15
    Thanks
    4
    Thanked 0 Times in 0 Posts

    Unhappy Very Basic PHP Help..

    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!

  • #2
    Senior Coder
    Join Date
    Apr 2010
    Posts
    1,394
    Thanks
    67
    Thanked 102 Times in 101 Posts
    Generally it's done like this

    PHP Code:
    <?php
    //Php coding
    ?>

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

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

  • Users who have thanked myfayt for this post:

    arslan89 (12-02-2010)

  • #3
    New Coder
    Join Date
    Aug 2009
    Posts
    15
    Thanks
    4
    Thanked 0 Times in 0 Posts
    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:

    Code:
     <?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.. ?

  • #4
    Regular Coder
    Join Date
    Jul 2009
    Posts
    186
    Thanks
    72
    Thanked 2 Times in 2 Posts
    You could just do that with HTML frames. I THINK this is what you are asking. So it would be something like this:

    Code:
    <?php
    
    $destination_page = $_GET['id'];
    
    ?>
    
    <html>
    <head><title>I rule</title></head>
    <body>
    Welcome to my website. Here is a frame:
    
    <frame src="./<?php echo $destination_page; ?>">
    
    </body>
    </html>
    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!
    Last edited by skcin7; 12-02-2010 at 02:55 AM.

  • Users who have thanked skcin7 for this post:

    arslan89 (12-02-2010)

  • #5
    Super Moderator
    Join Date
    May 2002
    Location
    Perth Australia
    Posts
    4,040
    Thanks
    10
    Thanked 92 Times in 90 Posts
    a modern version of your code (to account for register globals etc) would be something like...

    PHP Code:
    <?php
    $path
    ='/home/httpd/vhosts/blah.com/httpdocs/cutenews/';
    $file 'show_news.php';
    if(!empty(
    $_GET['id']) && file_exists($path.basename($_GET['id']).'.php')){
        
    $file=basename($_GET['id']).'.php'
    }
    include_once(
    $path.$file);
     
    ?>
    resistance is...

    MVC is the current buzz in web application architectures. It comes from event-driven desktop application design and doesn't fit into web application design very well. But luckily nobody really knows what MVC means, so we can call our presentation layer separation mechanism MVC and move on. (Rasmus Lerdorf)

  • Users who have thanked firepages for this post:

    arslan89 (12-02-2010)

  • #6
    New Coder
    Join Date
    Aug 2009
    Posts
    15
    Thanks
    4
    Thanked 0 Times in 0 Posts
    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.


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •