Jump to content

how to create dynamic page w/o database


pixeltrace

Recommended Posts

Hi,

 

we are doing a site w/o using database for our dynamic pages.

what i wanted to happen is i have

about us page

about.php

and inside i will have the following php codes

<? include (aboutuscontent.php);?>

and this page will contains some variables for the content like

<? $content1 ='html content here';
$content2 ='html content here';
$content3 ='html content here';
$content4 ='html content here';
?>

 

now on my aboutus.php i will have

this code

<?  if $_GET[id] == 1 {echo '$content1'; } ?>

 

my question is for my codes inside aboutuscontent.php

how will i be able to instead the html contents into so that i wont

need to change the HTML codes (e.g " to ' ' must place \  ... and so on)

 

hope you could help me with this.

 

thanks!

Link to comment
https://forums.phpfreaks.com/topic/94456-how-to-create-dynamic-page-wo-database/
Share on other sites

I do not fully understand your description of what you want, are you saying you do not want to go through the HTML and convert it into a string for php , like

$html1="<a href=\"this is some html\">";

 

anyway you are going about this the wrong way. Save all your unique content html as a seperate file

content1.htm,  content2.htm, content3.htm etc then use an include

 


<?php
$html_page=$_GET[id]; // I like to always put GET and POST into my own vars 

//check if the var is valid, using GET someone can pass it through browser  such as ?id=234329; use POST instead , good to still have a check though.

//IS id numeric or string? you may have to put the numers in " " to work.  "1" "4"

if (  ($html_page < 1 ) || ($html_page > 4 )  ){ //orwhatever the highest page id  number you have
echo"ERROR: Requested page not valid";
}else{
include  $path."content".$html_page.".htm";
}

just a slight twist, but you could span multiple server by doing:

 

echo html_get_contents('http://domain.com/file.html');

 

rather than the include.

 

I do that when I want to share certain html code with multiple sites.

 

The Above answer is a good answer, I just felt like adding this part. :P

 

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.