Welcome to the GoFuckYourself.com - Adult Webmaster Forum forums.

You are currently viewing our boards as a guest which gives you limited access to view most discussions and access our other features. By joining our free community you will have access to post topics, communicate privately with other members (PM), respond to polls, upload content and access many other special features. Registration is fast, simple and absolutely free so please, join our community today!

If you have any problems with the registration process or your account login, please contact us.

Post New Thread Reply

Register GFY Rules Calendar
Go Back   GoFuckYourself.com - Adult Webmaster Forum > >
Discuss what's fucking going on, and which programs are best and worst. One-time "program" announcements from "established" webmasters are allowed.

 
Thread Tools
Old 09-10-2003, 11:27 PM   #1
raster
Confirmed User
 
Join Date: Aug 2003
Posts: 784
PHP Script help

I've got a cgi script that allows me to add the output of a php script to an html page using the following line of code.

#insert : http://www.url.com/sript.php#

What I'm wondering is if someone could write me a couple of lines of code for script.php that would randomly select one line of information from a text file called text.txt.

This way, if I had the following line in my html file, the place where #insert : http://www.url.com/sript.php# is located, would be replaced by a random line of text from text.txt.

<a href="http://www.yahoo.com">#insert : http://www.url.com/sript.php#</a>

Thanks
raster is offline   Share thread on Digg Share thread on Twitter Share thread on Reddit Share thread on Facebook Reply With Quote
Old 09-10-2003, 11:40 PM   #2
JSA Matt
So Fucking Banned
 
Join Date: Aug 2003
Location: San Diego, CA
Posts: 5,464
keep it simple : )

PHP Code:
<?php
    $file        
"random.txt";
    
$file_Content    file($file);

    if (
count($file_Content) > 0)    {
        
$line $file_Content[rand(0,count($file_Content)-1)];
    
    echo 
$line;
    }
?>
JSA Matt is offline   Share thread on Digg Share thread on Twitter Share thread on Reddit Share thread on Facebook Reply With Quote
Old 09-10-2003, 11:41 PM   #3
myneid
Confirmed User
 
myneid's Avatar
 
Industry Role:
Join Date: Jan 2003
Location: Los Angeles
Posts: 736
i see now you beat me to it
__________________
Tanguy 0x7a69 inc. Programmer/President/CEO
http://www.0x7a69.com
A Leader in Programming since 1996
PHP, Ruby on Rails, MySQL, PCI DSS, and any Technical Consulting
myneid is offline   Share thread on Digg Share thread on Twitter Share thread on Reddit Share thread on Facebook Reply With Quote
Old 09-11-2003, 12:01 AM   #4
raster
Confirmed User
 
Join Date: Aug 2003
Posts: 784
Quote:
Originally posted by JSA Matt
keep it simple : )

PHP Code:
<?php
    $file        
"random.txt";
    
$file_Content    file($file);

    if (
count($file_Content) > 0)    {
        
$line $file_Content[rand(0,count($file_Content)-1)];
    
    echo 
$line;
    }
?>
Thanks very much, works great.
raster is offline   Share thread on Digg Share thread on Twitter Share thread on Reddit Share thread on Facebook Reply With Quote
Post New Thread Reply
Go Back   GoFuckYourself.com - Adult Webmaster Forum > >

Bookmarks



Advertising inquiries - marketing at gfy dot com

Contact Admin - Advertise - GFY Rules - Top

©2000-, AI Media Network Inc



Powered by vBulletin
Copyright © 2000- Jelsoft Enterprises Limited.