/    Sign up×
Community /Pin to ProfileBookmark

[HELP] Show selected content from HTML in PHP

Hi,

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

[CODE]
<body>
<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>
<(body>
[/CODE]

source

[CODE]
<body>
<div id=content1>Content to be shown</div>
<div id=content2>Content to be shown</div>
<div id=content3>Content to be shown</div>

</body>
[/CODE]

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.

[B]Can someone help me, please?[/B]

to post a comment
PHP

2 Comments(s)

Copy linkTweet thisAlerts:
@NogDogFeb 16.2014 — Here is a (crude) example of how you can drive everything from one PHP page:

index.php:
[code=php]
<!DOCTYPE html>
<head>
<title>Test</title>
<style type='text/css'>
body {
overflow: auto;
margin: 0;
padding: 0;
}
#sidebar {
float:left;
width:150px;
margin: 0;
padding:1em;
}
#content {
float: left;
margin: 0;
padding: 1em;
}
#head, #foot {
margin: 0;
padding: 1em;
clear:both;
}
</style>
</head>
<body>
<div id='head'>
<p>Static stuff at top of page goes here.</p>
</div>
<div id="sidebar">
<p>Static stuff at side of page goes here.</p>
</div>
<div id='content'>
<?php
// put dynamic content here, based on URL 'page' parameter
$page = 'default.html';
if(!empty($_GET['page'])) {
if(file_exists(basename($_GET['page'].'.html'))) {
$page = basename($_GET['page'].'.html');
}
}
readfile($page);
?>
</div>
<div id='foot'>
<p>Static stuff at bottom of page goes here.</p>
</div>
</body>
[/code]

default.html:
[code=html]
<h1>Default Content</h1>
<p>This is a test. It is only a test.</p>
[/code]

custom.html:
[code=html]
<h1>Custom Content</h1>
<p>This is another test. It is only a test.</p>
[/code]

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.
Copy linkTweet thisAlerts:
@Shime1994authorFeb 17.2014 — It's woks better than I wanted

[B]THANK YOU[/B]
×

Success!

Help @Shime1994 spread the word by sharing this article on Twitter...

Tweet This
Sign in
Forgot password?
Sign in with TwitchSign in with GithubCreate Account
about: ({
version: 0.1.9 BETA 6.17,
whats_new: community page,
up_next: more Davinci•003 tasks,
coming_soon: events calendar,
social: @webDeveloperHQ
});

legal: ({
terms: of use,
privacy: policy
});
changelog: (
version: 0.1.9,
notes: added community page

version: 0.1.8,
notes: added Davinci•003

version: 0.1.7,
notes: upvote answers to bounties

version: 0.1.6,
notes: article editor refresh
)...
recent_tips: (
tipper: @nearjob,
tipped: article
amount: 1000 SATS,

tipper: @meenaratha,
tipped: article
amount: 1000 SATS,

tipper: @meenaratha,
tipped: article
amount: 1000 SATS,
)...