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 13 of 13
  1. #1
    New Coder
    Join Date
    Jul 2009
    Posts
    17
    Thanks
    12
    Thanked 0 Times in 0 Posts

    Website news question

    Ok i really new to web making and i have a question i was wondering if you could help me with.

    Lets say you have a website with your links on the left side and news in the middle
    How can i make it so when i click one of the links at the side the middle where the news is changes but the left stays the same?

    Sorry if you dont understand i will try to be more clear if you dont know what i mean.

    Thanks!

  • #2
    Senior Coder
    Join Date
    May 2005
    Posts
    2,137
    Thanks
    96
    Thanked 72 Times in 72 Posts
    There is a few ways of doing this. With PHP you can have a template file, and it loads the page when you click on the links and shows the new content.

    In javascript, it doesn't have to reload the page, and it will change.
    Rowsdower! has accused me of having mental problems, and the administrator allowed it. What a great forum huh?

  • #3
    New Coder
    Join Date
    Jul 2009
    Posts
    17
    Thanks
    12
    Thanked 0 Times in 0 Posts
    Hm now how would i go about doing the first option

  • #4
    Master Coder
    Join Date
    Jun 2003
    Location
    Cottage Grove, Minnesota
    Posts
    9,512
    Thanks
    8
    Thanked 1,090 Times in 1,081 Posts
    Will the links on the left side keep changing, or do they always stay the same?

    Maybe you have a web page you can show us?

  • #5
    New Coder
    Join Date
    Jul 2009
    Posts
    17
    Thanks
    12
    Thanked 0 Times in 0 Posts
    The links will always stay the same.

    And sorry i have not uploaded my website yet.

  • #6
    Master Coder
    Join Date
    Jun 2003
    Location
    Cottage Grove, Minnesota
    Posts
    9,512
    Thanks
    8
    Thanked 1,090 Times in 1,081 Posts
    You posted this in the PHP section ... I assume you know PHP?
    And do your pages have the extension of .php (instead of .html)?

    How are you doing the "news articles"?
    Are those some simple text files that you upload?

    The answer to your question is really depending on the structure of
    your "news items" or "articles" ... when the links on the left are clicked,
    how you determine which articles to show. We need more information
    on what the news content is.

    Maybe if you describe what your site is about ... that might help.


    .

  • #7
    New Coder
    Join Date
    Jul 2009
    Posts
    17
    Thanks
    12
    Thanked 0 Times in 0 Posts
    uhm its just a little project im doing to learn php.

    I want the News to be in php format because i want to add polls and stuff.
    sorry i can't be that much of a help im really new to all this.

  • #8
    New Coder
    Join Date
    Jul 2009
    Posts
    17
    Thanks
    12
    Thanked 0 Times in 0 Posts
    Pretty much this is how i would like it to work.

    Lets say i have 3 links

    News (News.php)
    Updates (Update.php)
    Help (help.php)

    When one of those are clicked i want my website to swap what is currently in the middle to whatever i click and everything else stay the same.

  • #9
    Senior Coder
    Join Date
    May 2005
    Posts
    2,137
    Thanks
    96
    Thanked 72 Times in 72 Posts
    Yeah that is just a static template. You need to build your layout (section with your links and header, footer, etc). Then build like news.php and in the middle post your news, save it as News.php and then either edit the same file or copy the same coding to a blank one and build Update and save as Update.php etc. Do this for all of them, and just change the middle content area.

    After the template and pages are finished, if you want to change news from an Administrator Control Panel, you can easily and quickly convert it to read from it.
    Rowsdower! has accused me of having mental problems, and the administrator allowed it. What a great forum huh?

  • #10
    Master Coder
    Join Date
    Jun 2003
    Location
    Cottage Grove, Minnesota
    Posts
    9,512
    Thanks
    8
    Thanked 1,090 Times in 1,081 Posts
    OK ...

    So you have your three files.

    They contain any PHP or HTML you want,
    but they don't contain any <head> stuff,
    only content that would appear in the middle
    of a page.

    You have another PHP script called "header.php".
    That script has your main web page header, <head> <title> <meta>, etc.

    You have another PHP script called "footer.php"
    That script has your main web page footer ... copyright, all rights reserved, etc.

    Your main page (with the 3 links) is called "index.php".

    Your "index.php" would look something like this:
    PHP Code:
    <?php

    // default display
    $display="news.php";

    // get any variables from the links
    $page=$_GET['p'];

    if(
    $page=="n"){
    $display="news.php";
    }
    if(
    $page=="u"){
    $display="updates.php";
    }
    if(
    $page=="h"){
    $display="help.php";
    }
    ?>

    <?php include("header.php");?>

    <body>

    blah blah

    <div id="left_column">
    <a href="index.php?p=n">News Page</a><br />
    <a href="index.php?p=u">Updates Page</a><br />
    <a href="index.php?p=h">Help Page</a><br />
    </div>

    <div id="middle_content">
    <?php include($display);?>
    </div>

    <div id="footer">
    <?php include("footer.php");?>
    </div>

    </body>
    </html>

  • #11
    New to the CF scene
    Join Date
    Jan 2010
    Posts
    1
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Joliese tan

    where to learn PHP tell me. I am interested in PHP.
    Joliese tan

  • #12
    Master Coder
    Join Date
    Jun 2003
    Location
    Cottage Grove, Minnesota
    Posts
    9,512
    Thanks
    8
    Thanked 1,090 Times in 1,081 Posts
    You can find books on Amazon.com
    or free tutorials and examples by searching on Google: PHP tutorials

  • #13
    New Coder
    Join Date
    Jan 2010
    Location
    The Netherlands
    Posts
    53
    Thanks
    10
    Thanked 0 Times in 0 Posts
    @ Isabellalara: This is the wrong place to ask, but buy the book "PHP for dummies", that will help you.

    Ontopic:

    Working with frames is also a possibility.
    This can be done in HTML or PHP.

    You create a menu frame and a content frame.
    In the menu frame you place a HTML or PHP page with the links.
    These links point to your News, Updates and Help pages to be shown in the content frame.

    Just like mlseim did with the DIVs.

    In the index file:
    PHP Code:
    <iframe src="menu.php" frameborder="1" height="100%" width="150" scrolling="no" 
    name="sidemenu"></iframe
    In the menu.php:
    PHP Code:
    <class="type3" href="news.php" target="_content"><font size="-1">News</font></a
    Hope this helps you further.


  •  

    Posting Permissions

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