Programming Forums
User Name Password Register
 

RSS Feed
FORUM INDEX | TODAY'S POSTS | UNANSWERED THREADS | ADVANCED SEARCH

Reply
 
Thread Tools Display Modes
Old Jan 10th, 2007, 11:34 PM   #1
Mr. John
Newbie
 
Join Date: Jul 2006
Location: In front of my computer
Posts: 6
Rep Power: 0 Mr. John is on a distinguished road
Random Fact Script

Hi, I am completely new to PHP so please understand if I don't understand . I need a php scipt to put on my site that creates a random fact from a txt file. I have tried so many, but none of them seem to work. Does anyone know one or know where to good a good one?
Mr. John is offline   Reply With Quote
Old Jan 11th, 2007, 12:46 AM   #2
DaWei
Resident Grouch
 
DaWei's Avatar
 
Join Date: Jun 2005
Posts: 6,453
Rep Power: 10 DaWei is on a distinguished road
Nope, don't know of any, but it's reasonably easy to do. Read the file into an array, one line (fact) per element. Pick a random number in the range 0 to array length - 1 (integral). Fetch the fact from the element having that number as its index.
__________________
Abstraction doesn't make it impossible to write bad code; it makes it possible to write superior code.
Contributor's Corner: Grumpy on C++ Exceptions DaWei on Pointers
DaWei is offline   Reply With Quote
Old Jan 11th, 2007, 1:39 AM   #3
grimpirate
King of Portal
 
grimpirate's Avatar
 
Join Date: Sep 2005
Posts: 437
Rep Power: 4 grimpirate is on a distinguished road
Send a message via Yahoo to grimpirate
Mr. John there is a previous topic in the forum regarding just what you're looking for. However it's random quotes rather than facts, but the content doesn't matter as it achieves the effect you're looking for. Here's the thread.
http://www.programmingforums.org/for...or-script.html
__________________
Lo, there do I see my father. 'Lo, there do I see My mother, and my sisters, and my brothers. 'Lo, there do I see The line of my people... Back to the beginning. 'Lo, they do call to me. They bid me take my place among them. In the halls of Valhalla... Where the brave... May live... ...forever.. GrimBB | Mimesis
grimpirate is offline   Reply With Quote
Old Jan 11th, 2007, 2:12 AM   #4
Mr. John
Newbie
 
Join Date: Jul 2006
Location: In front of my computer
Posts: 6
Rep Power: 0 Mr. John is on a distinguished road
Thank you for the link. I was wondering if there was anyway I could put this code into a .tpl file. I want to add this to my phpBB board header but it doesn't seem to be working.
Mr. John is offline   Reply With Quote
Old Jan 11th, 2007, 2:52 AM   #5
titaniumdecoy
Expert Programmer
 
titaniumdecoy's Avatar
 
Join Date: Nov 2005
Posts: 909
Rep Power: 3 titaniumdecoy is on a distinguished road
Send a message via AIM to titaniumdecoy
You need to install the eXtreme Styles mod from phpbbstyles.com. One of its features is to allow PHP in template (.tpl) files.
titaniumdecoy is offline   Reply With Quote
Reply

Bookmarks

« Previous Thread in Forum | Next Thread in Forum »

Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Median/Mode in arrays? {Need help} Java|Tera Java 27 Nov 29th, 2005 11:50 AM
PHP random quote generator script grimpirate PHP 10 Sep 24th, 2005 10:22 AM
A simple perl script satimis Perl 3 Aug 15th, 2005 10:31 AM
Bash Script Help pelon Bash / Shell Scripting 2 Feb 28th, 2005 4:58 PM




DaniWeb IT Discussion Community
All times are GMT -5. The time now is 5:02 AM.

Powered by vBulletin® Version 3.7.0, Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Copyright ©2007 DaniWeb® LLC