For quite a while now, I have used the PHP include code on my site. I looked like this:
<?if($id != '') {include("" . $id . ".html"); } else { include("main.html"); } ?>
I just uploaded PHP fusion on my server and it said to add this code to where you want the news to appear on your site:
<?php include "news/upload/news.php";?>
Now I want to know how to include news.php on my site and still keep the old code. Any help?<?if($id != '') {include("" . $id . ".php"); } else { include("main.php"); } ?>
May as well end the main.html file and all your other files *.php. Just go to 'ThisPHPFileName.php?id=news' and it will take you to your news page.
It's really just a matter of changing .html to .php.
You could also use this code, as I like it better:
<?
if (!$id)
{
$id = main;
}
include "$id.php";
?>
I think this is what you meant, right?
BleuIceI dont' understand how this works. How would I go about using this? Do I made some html between <?php ?> and give it a variable? And then do I use <?php include($variable); ?> on the page I want it included on?
?josh, you only include specific pages.
the code that BleuIce could make $id be whatever he chooses (if he changes his code alittle)
so if i had $id = moo, it would include moo.php, but for his if $id doesnt equal anything make $id = moo.Nope, still dont' understand.jsut insert this to where ever you want the code to appear on your site
<?php include "news/upload/news.php";?>
Josh, inlcudes include a whole page or a variable form anotehr page, it is always seperate from your orignal page.Why would you want to include a whole page? And by including a variable, could you give an html code a variable and just use includes to include just that variable and it will actually put the code on the page?you cannot include a variable, only pages.
you can however make a page that did something and echo a variable and then include that page into your main page.
includes come in hand when you want a page to show on ever page on your site so all you have to do is edit opne page and not ever single page to do the whole site, make sense?oh!
I see now scoutt. But how would you change little parts of each page so they're not all identical?no you can't unless you do seperate files. that is the purpose of including a file on a lot of pages. they are the same. like a menu or something
<?if($id != '') {include("" . $id . ".html"); } else { include("main.html"); } ?>
I just uploaded PHP fusion on my server and it said to add this code to where you want the news to appear on your site:
<?php include "news/upload/news.php";?>
Now I want to know how to include news.php on my site and still keep the old code. Any help?<?if($id != '') {include("" . $id . ".php"); } else { include("main.php"); } ?>
May as well end the main.html file and all your other files *.php. Just go to 'ThisPHPFileName.php?id=news' and it will take you to your news page.
It's really just a matter of changing .html to .php.
You could also use this code, as I like it better:
<?
if (!$id)
{
$id = main;
}
include "$id.php";
?>
I think this is what you meant, right?
BleuIceI dont' understand how this works. How would I go about using this? Do I made some html between <?php ?> and give it a variable? And then do I use <?php include($variable); ?> on the page I want it included on?
?josh, you only include specific pages.
the code that BleuIce could make $id be whatever he chooses (if he changes his code alittle)
so if i had $id = moo, it would include moo.php, but for his if $id doesnt equal anything make $id = moo.Nope, still dont' understand.jsut insert this to where ever you want the code to appear on your site
<?php include "news/upload/news.php";?>
Josh, inlcudes include a whole page or a variable form anotehr page, it is always seperate from your orignal page.Why would you want to include a whole page? And by including a variable, could you give an html code a variable and just use includes to include just that variable and it will actually put the code on the page?you cannot include a variable, only pages.
you can however make a page that did something and echo a variable and then include that page into your main page.
includes come in hand when you want a page to show on ever page on your site so all you have to do is edit opne page and not ever single page to do the whole site, make sense?oh!
I see now scoutt. But how would you change little parts of each page so they're not all identical?no you can't unless you do seperate files. that is the purpose of including a file on a lot of pages. they are the same. like a menu or something