Rotate Different Copyrighted Content
Moderator: General Moderators
Rotate Different Copyrighted Content
Hi guys
I added some php include statements into my main site pages and the include statements call a file called article.inc.
What I would like to do is rotate different articles on my site - I have written over 50 articles and would like to rotate them so its fresh content everytime someone visits.
At present I have <!--#include virtual="article.inc" --> on my main page.
Any ideas how I would get it to call for example article1.inc, article2.inc up to say article50.inc - all are which my own articles?
Thanks in advance
Nikhil
I added some php include statements into my main site pages and the include statements call a file called article.inc.
What I would like to do is rotate different articles on my site - I have written over 50 articles and would like to rotate them so its fresh content everytime someone visits.
At present I have <!--#include virtual="article.inc" --> on my main page.
Any ideas how I would get it to call for example article1.inc, article2.inc up to say article50.inc - all are which my own articles?
Thanks in advance
Nikhil
Code: Select all
<?php
$art = mt_rand(0, 50);
if($art == "0") {
echo "<!--#include virtual=\"article.inc\" -->";
} else {
echo "<!--#include virtual=\"article" . $art . ".inc\" -->";
}
?>
Last edited by William on Tue Jul 07, 2009 11:46 am, edited 2 times in total.
- n00b Saibot
- DevNet Resident
- Posts: 1452
- Joined: Fri Dec 24, 2004 2:59 am
- Location: Lucknow, UP, India
- Contact:
Code: Select all
$art = mt_rand(0, 50);Code: Select all
if($art == "0") {
echo "<!--#include virtual=\"article.inc\" -->";
} else {
echo "<!--#include virtual=\"article" . $art . ".inc\" -->";
}No problem. Also that is not a PHP include. To include using PHP you need to do the following:
and if you want to do that with my code use this:
Code: Select all
<?php
include("filename.ext");
?>
Code: Select all
<?php
$art = mt_rand(0, 50);
if($art == "0") {
include("article.inc");
} else {
include("article" . $art . ".inc");
}
?>
Last edited by William on Tue Jul 07, 2009 11:46 am, edited 1 time in total.
- n00b Saibot
- DevNet Resident
- Posts: 1452
- Joined: Fri Dec 24, 2004 2:59 am
- Location: Lucknow, UP, India
- Contact:
- n00b Saibot
- DevNet Resident
- Posts: 1452
- Joined: Fri Dec 24, 2004 2:59 am
- Location: Lucknow, UP, India
- Contact:
Update
Hi guys,
Thanks again for your help with this but I am having some trouble getting anything to display on my main site. I have created a file called rotate.php which contains the following:
<?php
$art = mt_rand(0, 50);
if($art == "0") {
include("test.txt");
} else {
include("test" . $art . ".txt");
}
?>
When I open up the rotate.php in a browser the articles rotate e.g test28.txt etc
However when I try the following in a file included on my main site I get a blank space i.e nothing is displayed in the area where it should be displaying the test*.txt
<!--#include virtual="/rotate.php" -->
I've even tried <!--#include virtual="rotate.php" -->- without the trailing
Any ideas please?
Thanks in advance
Regards,
Nikhil
Thanks again for your help with this but I am having some trouble getting anything to display on my main site. I have created a file called rotate.php which contains the following:
<?php
$art = mt_rand(0, 50);
if($art == "0") {
include("test.txt");
} else {
include("test" . $art . ".txt");
}
?>
When I open up the rotate.php in a browser the articles rotate e.g test28.txt etc
However when I try the following in a file included on my main site I get a blank space i.e nothing is displayed in the area where it should be displaying the test*.txt
<!--#include virtual="/rotate.php" -->
I've even tried <!--#include virtual="rotate.php" -->- without the trailing
Any ideas please?
Thanks in advance
Regards,
Nikhil
Problem with code
Hi guys,
I have tried varying the code as listed below but I get the following error:
Parse error: parse error, unexpected '<' on line 4
I was told to try the following code but it resulted in the error above. I can't seem to find where the problem lies. Code is as follows:
<?php
$art = mt_rand(0, 50);
if($art == "0") {
<!--#include virtual="<?="test.txt" ?>" -->
} else {
include("test" . $art . ".txt");
<!--#include virtual="<?="test" . $art . ".txt" ?>" -->
}
?>
Thanks again for your help.
Nikhil
I have tried varying the code as listed below but I get the following error:
Parse error: parse error, unexpected '<' on line 4
I was told to try the following code but it resulted in the error above. I can't seem to find where the problem lies. Code is as follows:
<?php
$art = mt_rand(0, 50);
if($art == "0") {
<!--#include virtual="<?="test.txt" ?>" -->
} else {
include("test" . $art . ".txt");
<!--#include virtual="<?="test" . $art . ".txt" ?>" -->
}
?>
Thanks again for your help.
Nikhil