PDA

View Full Version : PHP includes



мϊкэ
30-05-2005, 07:58 PM
Anybody know how to make some parts not appear in a php include

this is the php code on one of my pages home.php which shows the last piece of news


<?php include 'news.php'; echo "$rnews" ?>

then on my news.php this is the code:


<?php

$rnews = 'The Last piece of news';
$news = ' All the rest of the news';

echo "$rnews <br> $news"

?>

on the home.php page how can i make this part not appear?


echo "$rnews <br> $news"

iRoss
30-05-2005, 08:01 PM
Don't include it ?

I mean like. Not at all just leave it off the page ?

мϊкэ
30-05-2005, 08:06 PM
but i need it to show when they go onto the news page :p

Mentor
30-05-2005, 09:09 PM
im confused.
Why dont you just include it on the pages that need it?

jamie5k
30-05-2005, 09:15 PM
im really confused with what u want try explaining it more?

мϊкэ
30-05-2005, 10:14 PM
doesnt matter now ive figured it out :p

<?php
if( $rnews == 1 )
{
echo "RECENT NEWS";
}
if( $news == 1 )
{
echo "OLD NEWS";
}
?>
so then if i only want the recent news displayed:
http://www.site.com/news.php?rnews=1
and for just news:
http://www.site.com/news.php?news=1
and if i want both of them displayin:
http://www.site.com/news.php?news=1&rnews=1

Want to hide these adverts? Register an account for free!