Go Back   PCMech Forums > Help & Discussion > Web Design / Development

Need Some Help? Type Your Keywords Here:

Reply
 
LinkBack Thread Tools Search this Thread Rate Thread Display Modes
Old 12-31-2003, 05:45 PM   #1
Barefoot on the Moon!
Staff
Premium Member
 
Force Flow's Avatar
 
Join Date: Aug 2002
Location: Northeastern USA
Posts: 13,385
Displaying random lines from a *.txt on a webpage

I'm looking for a way to display random (or ordered, doesn't matter) lines of text from a text file on a webpage. I've seen it done before and was wondering how it could be done.
__________________
There are two secrets to staying young, being happy, and achieving success. You have to laugh and find humor every day, and you have to have a dream.
Force Flow is offline   Reply With Quote
Old 01-01-2004, 09:55 PM   #2
Barefoot on the Moon!
Staff
Premium Member
 
Force Flow's Avatar
 
Join Date: Aug 2002
Location: Northeastern USA
Posts: 13,385
*bumpity bump*
Force Flow is offline   Reply With Quote
Old 01-03-2004, 10:31 PM   #3
Barefoot on the Moon!
Staff
Premium Member
 
Force Flow's Avatar
 
Join Date: Aug 2002
Location: Northeastern USA
Posts: 13,385
Any suggestions? What languages could I accomplish this with?
Force Flow is offline   Reply With Quote
Old 01-04-2004, 02:25 PM   #4
aym
Registered User
 
aym's Avatar
 
Join Date: Nov 2001
Posts: 1,965
Hi force_flow2002,
I wonder if it's possible in JavaScript, but I prefer to do it server-side, so if your host supports PHP, read on!
PHP Code:
<?php
$lines 
file('mytext.txt');
//now $lines is an array, each element of the array is a line in the file
$num rand() % count($lines);
echo 
$lines[$num];
?>
Of course, you can do it in any other server-side language, but I happen to know PHP the best
aym is offline   Reply With Quote
Old 01-04-2004, 05:08 PM   #5
Barefoot on the Moon!
Staff
Premium Member
 
Force Flow's Avatar
 
Join Date: Aug 2002
Location: Northeastern USA
Posts: 13,385
I suspected it would be done with some server-side language. Rats. That and Flash are my great webpage weaknesses.

Thanks anyway, aym_7
Force Flow is offline   Reply With Quote
Old 01-14-2004, 04:32 PM   #6
Member (8 bit)
 
bmrmrb's Avatar
 
Join Date: Jan 2004
Location: europe
Posts: 172
i have seen something very similar with javascript. check out javascript.internet.com
bmrmrb is offline   Reply With Quote
Old 01-15-2004, 11:44 AM   #7
Member (8 bit)
 
bmrmrb's Avatar
 
Join Date: Jan 2004
Location: europe
Posts: 172
knew it was somewhere! found it here
just replace the "Tip **" with your text

hope this helps!
bmrmrb is offline   Reply With Quote
Old 01-15-2004, 05:26 PM   #8
aym
Registered User
 
aym's Avatar
 
Join Date: Nov 2001
Posts: 1,965
tips here are hardcoded into the page and not saved to a separate txt file.
aym is offline   Reply With Quote
Old 01-15-2004, 06:55 PM   #9
Barefoot on the Moon!
Staff
Premium Member
 
Force Flow's Avatar
 
Join Date: Aug 2002
Location: Northeastern USA
Posts: 13,385
Thanks anyway guys. I managed to find out how to do it.

Thought this thread was long dead
Force Flow is offline   Reply With Quote
Old 01-16-2004, 02:04 PM   #10
aym
Registered User
 
aym's Avatar
 
Join Date: Nov 2001
Posts: 1,965
so how did you do it? JavaScript? PHP? Or something else?
and it's not me, bmrmrb summoned the thread back to life
aym is offline   Reply With Quote
Reply

Bookmarks

Still Need Help? Type Your Keywords Here:


Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes Rate This Thread
Rate This Thread:

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 On
Trackbacks are On
Pingbacks are On
Refbacks are On



All times are GMT -5. The time now is 12:44 AM.
Powered by vBulletin® Version 3.8.7
Copyright ©2000 - 2012, vBulletin Solutions, Inc.
SEO by vBSEO 3.6.0 PL2