Results 1 to 3 of 3

Thread: [HELP] Show selected content from HTML in PHP

  1. #1
    Join Date
    Feb 2014

    Question [HELP] Show selected content from HTML in PHP


    I would like to create a page that has "similar" functionality like 'Facebook'. What I mean is the dynamic page in center that shows you posts from another people etc.. Basically, create one page that stores all stuff to be shown and second one that shows it.

    The page would look like this:
    Top banner and menu alongside with side panel are fixed to page. In between them is frame, that displays "content; a "content.php". This "content.php" gets its content to show from source file "source.html". Source.html stores all information/ data that has to be shown through "content.php" in from of <div> tags (blocks). So it is like this:
    main page + content
    <a href="content1" target="frame">link to content1</a>
    <a href="content2" target="frame">link to content3</a>
    <a href="content3" target="frame">link to content3</a>
    <iframe id="frame" src="centent.php" name="frame"></iframe>
    <div id=content1>Content to be shown</div>
    <div id=content2>Content to be shown</div>
    <div id=content3>Content to be shown</div>
    So if I click the link "content1" on main page, the "content.php" will take info/data from "source.html" that is listed as "content1" and shows it in the frame. Not entire "source" page, only part that is listed as "content1".

    The question is, how do I do it?
    The page isn't that much problem as the PHP. I know there are these stuff in PHP (in between body tags are these <? ?> ), but i don't know what tags / how to use them to show only a certain content (div/block) from file.

    Maybe you're asking: "why don't you create separate pages for each content?" (like content1.html, content2.html...) The reason for this is, I'm making a school project and I have to use PHP and I don't know where to use it. And secondly, if every page would have their own file, I would lost track of it. So that's why I want to use it this way.

    Can someone help me, please?

  2. #2
    Join Date
    Aug 2004
    Here is a (crude) example of how you can drive everything from one PHP page:

    PHP Code:
    <!DOCTYPE html>
    <style type='text/css'>
        body {
            overflow: auto;
            margin: 0;
            padding: 0;
        #sidebar {
            margin: 0;
        #content {
            float: left;
            margin: 0;
            padding: 1em;
        #head, #foot {
            margin: 0;
            padding: 1em;
        <div id='head'>
            <p>Static stuff at top of page goes here.</p>
        <div id="sidebar">
            <p>Static stuff at side of page goes here.</p>
        <div id='content'>
    // put dynamic content here, based on URL 'page' parameter
    $page 'default.html';
    $_GET['page'])) {
    file_exists(basename($_GET['page'].'.html'))) {
    $page basename($_GET['page'].'.html');
        <div id='foot'>
            <p>Static stuff at bottom of page goes here.</p>
    HTML Code:
    <h1>Default Content</h1>
    <p>This is a test. It is only a test.</p>
    HTML Code:
    <h1>Custom Content</h1>
    <p>This is another test. It is only a test.</p>
    If you call index.php with no additional parameters, you will get the default content. If you call it as index.php?page=custom, you'll get the content in custom.html.
    "Well done....Consciousness to sarcasm in five seconds!" ~ Terry Pratchett, Night Watch

    How to Ask Questions the Smart Way (not affiliated with this site, but well worth reading)

    My Blog
    cwrBlog: simple, no-database PHP blogging framework

  3. #3
    Join Date
    Feb 2014
    It's woks better than I wanted


Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Posting Permissions

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