Jump to content

Dynamic content on my index.php


Dood77

Recommended Posts

I'm currently using an index.php that displays the title, menu etc. and grabs a string from the address (/index.php&content=*blah*) to get the content for the page externally using include. (I don't have the code with me at the moment, I forgot it at home)

It works similarly to this:

<body>
<table>
<tr><td>
[menu]
</td>
<td>
<?php
$content = $_get["content"] . ".htm"
include($content)
?>
</td></tr>
</table>

The syntax is probably wrong there but thats not my issue. It works fine, but the menu I have is flash and whenever I click a link on it the whole page has to reload and the flash has to reload and it flashes (no pun intended) white. I realize this isn't really a php problem per se, but I figure you guys can help anyway, maybe theres a better way to dynamically load the content in the page without having to reload all the other stuff? Before I decided to go with php I was using javascript to dynamically change the src attribute to an iframe, but the iframe height can't very easily be calculated and changed dynamically...

So, yeah, responses appreciated and all that ;)

Link to comment
https://forums.phpfreaks.com/topic/50526-dynamic-content-on-my-indexphp/
Share on other sites

If you still want to do it like that, you can do:

 

$content = $_GET['content'];
//$content = mysql_real_escape_string($content);
//only if you're pre-connecting to a database
if($content){
$content_new = "$content.htm";

if(file_exists($content_new)){
include "$content_new";
}else {
echo "This file does not exist";
}
}

Yeah, like I said, I didn't have the original code with me at the moment.

But actually I do now:

<head>
<?php
$content = $_GET["content"];
?>
</head>
<body>
<?php
if (strlen($content) == 0){
header ("Location: index.php?content=intro");
} elseif (!file_exists($content . ".htm")){
$content = "error";
}
include($content . ".htm");
?>
</body>

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.