![]() |
| ||||||||
|
|||||||
![]() |
|
|
LinkBack | Thread Tools |
|
|
#1 |
|
Warrior Member
Join Date: Aug 2009
Posts: 13
Thanks: 0
Thanked 0 Times in 0 Posts
|
Hi
I would like to know if anyone can suggest a php script that will allow me to rotare articles on my web page. For example I have 5 articles and I would like to show a different article to each new visitor on one page. Thanks
|
|
One4u Free PHP Web Hosting. We offer 250mb of quality webspace, 6GB of Bandwidth, PHP and Mysql, FTP Account and much more Click Here To Create Your Free Hosting Account
|
|
|
|
|
|
|
#2 |
|
Active Warrior
Join Date: Nov 2009
Location: UK
Posts: 40
Thanks: 0
Thanked 5 Times in 5 Posts
|
This is a quick one, normally the array is links for redirects
<?php //array of the articles text or reference to them from a database $arr = array('one','two','three','four','five') $rand = rand(0,4); $article = $arr[$rand]; echo $article ?> if you want a proper script give me more details. ie where you store the articles. wont take long to knock one up |
|
Last edited by jwlnewsome; 11-04-2009 at 03:09 PM. Reason: adding last line |
|
|
|
|
|
|
#3 |
|
Warrior Member
Join Date: Aug 2009
Posts: 13
Thanks: 0
Thanked 0 Times in 0 Posts
|
Thx jwlnewsome
I have just been trying that code snippet and it does not work or atleast I cannot make it work.If there is a code snippet that can be put on web pages to allow random articles from one folder asigned to that web page to show all the articles in that folder randomly when a vistior visits. So each page will have its own folder filled with articles to be shown randomly on that page. |
|
One4u Free PHP Web Hosting. We offer 250mb of quality webspace, 6GB of Bandwidth, PHP and Mysql, FTP Account and much more Click Here To Create Your Free Hosting Account
|
|
|
|
|
|
|
#4 |
|
Advanced Warrior
War Room Member
Join Date: Sep 2008
Location: Honolulu, Hawaii, USA (Currently in Montreal Canada)
Posts: 813
Blog Entries: 1
Thanks: 138
Thanked 217 Times in 146 Posts
|
Actually the code jwlnewsome posted is essentially what you need, perhaps you left off the closing semicolons on the array and echo lines like jwlnewsome did in their post. Essentially you're defining and array of articles and using a random number generator to make a selection in the array.
Check your code for syntax errors and try again! Bill |
|
|
|
|
|
#5 |
|
Warrior Member
War Room Member
Join Date: Apr 2009
Posts: 28
Thanks: 2
Thanked 1 Time in 1 Post
|
That was a nice bit of base code Bill - the only other option that I would have considered would be adding a dynamic database field that updates at pageload - plus a table containing the banner pics of course...
|
|
|
|
|
|
#6 |
|
Advanced Warrior
War Room Member
Join Date: Sep 2008
Location: Honolulu, Hawaii, USA (Currently in Montreal Canada)
Posts: 813
Blog Entries: 1
Thanks: 138
Thanked 217 Times in 146 Posts
|
Actually da1fitz the code was posted by jwlnewsome, I was just commenting on it.
This link may be useful to the OP, there are several scripts to choose from here: PHP Random Text | Randomizing Scripts & Programs | Hot Scripts Bill |
|
|
|
|
|
#7 |
|
Warrior Member
Join Date: Aug 2009
Posts: 13
Thanks: 0
Thanked 0 Times in 0 Posts
|
Thanks all for your help I have managed to get something working with the code that jwlnewsome posted. It took a little reasearch on google and a bit of cursing but it is now working the way I wanted it to work
![]() Again thans all for your help.
|
|
One4u Free PHP Web Hosting. We offer 250mb of quality webspace, 6GB of Bandwidth, PHP and Mysql, FTP Account and much more Click Here To Create Your Free Hosting Account
|
|
|
|
|
![]() |
|
| Tags |
| free, php, rotation, script, suggestions |
| Thread Tools | |
|
|
![]() |