pixeltrace Posted March 5, 2008 Share Posted March 5, 2008 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! Quote Link to comment https://forums.phpfreaks.com/topic/94456-how-to-create-dynamic-page-wo-database/ Share on other sites More sharing options...
Agricola Posted March 5, 2008 Share Posted March 5, 2008 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"; } Quote Link to comment https://forums.phpfreaks.com/topic/94456-how-to-create-dynamic-page-wo-database/#findComment-483833 Share on other sites More sharing options...
AV1611 Posted March 5, 2008 Share Posted March 5, 2008 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. Quote Link to comment https://forums.phpfreaks.com/topic/94456-how-to-create-dynamic-page-wo-database/#findComment-483877 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.