Forum Index
RegisterSearchFAQMemberlistUsergroupsLog in
Random Slogan Code

 
Reply to topic    Forum Index » Skins and snippets View previous topic
View next topic
Random Slogan Code
Author Message
scottdallas



Joined: 04 May 2006
Posts: 1843
Location: US

Post Random Slogan Code Reply with quote
I found this code last night and I thought someone else might find good ways to use it in their sites. It really doesn't have anything to do with cutenews.ru but it can be used on any website to generate dynamic content anywhere you like. You can see it working on www.tastypolls.com right underneath the logo. On every page refresh it grabs a new slogan from this list.



Code:
<?

$random_textual = array("First text.",

                    "Second text.",

                    "Third text.",

                    "Just copy and paste these lines to add more random text.");

srand(time());

$sizeof = count($random_textual);

$randomslogan = (rand()%$sizeof);

print("$random_textual[$randomslogan]");

?>




Just put it wherever you want random text to appear and it'll grab a random one from the list.

_________________
www.scottdizzle.com uses cnr Smile
last update: 07-22-08: 8:30 pm

Last edited by scottdallas on Thu May 10, 2007 9:56 pm; edited 1 time in total
Sun Apr 29, 2007 8:55 am View user's profile Send private message Visit poster's website AIM Address
Guest








Please login to hide the ads.

scottdallas



Joined: 04 May 2006
Posts: 1843
Location: US

Post Reply with quote
I just noticed that this interferes with the cutenews.ru include code for show_news.php which is sucky. It will mess up the order of posts somehow magically and cause strange error message when no news is on the page.



Woah, look at this:

http://www.google.com/search?hl=en&q=random+slogan+code&btnG=Search



Update: I changed the code above. It works now with cutenews.ru

_________________
www.scottdizzle.com uses cnr Smile
last update: 07-22-08: 8:30 pm

Last edited by scottdallas on Thu May 10, 2007 9:56 pm; edited 1 time in total
Sat May 05, 2007 3:18 pm View user's profile Send private message Visit poster's website AIM Address
Ramon



Joined: 12 Oct 2005
Posts: 462
Location: Hoogeveen, NL

Post Reply with quote
Huhu _O_



Try this scott



Code:
<?

$random_text5 = array("First text.",

                    "Second text.",

                    "Third text.",

                    "Just copy and paste these lines to add more random text.");

srand(time());

$sizeof020 = count($random_text5);

$random18 = (rand()%$sizeof020);

print("$random_text5[$random18]");

?>


_________________
Sun May 06, 2007 2:00 am View user's profile Send private message Visit poster's website
scottdallas



Joined: 04 May 2006
Posts: 1843
Location: US

Post Reply with quote
Is $random_text used in cutenews.ru? I figured it must be. I didn't try the code yet

_________________
www.scottdizzle.com uses cnr Smile
last update: 07-22-08: 8:30 pm
Sun May 06, 2007 6:53 am View user's profile Send private message Visit poster's website AIM Address
FI-DD
Admin


Joined: 22 Sep 2005
Posts: 2736
Location: Germany

Post Reply with quote
I think $random is used in the other random news hack.
Wed May 09, 2007 5:46 pm View user's profile Send private message
scottdallas



Joined: 04 May 2006
Posts: 1843
Location: US

Post Reply with quote
Thanks guys I fixed the code and updated it above after testing it. Works fine.

_________________
www.scottdizzle.com uses cnr Smile
last update: 07-22-08: 8:30 pm
Thu May 10, 2007 9:57 pm View user's profile Send private message Visit poster's website AIM Address
scottdallas



Joined: 04 May 2006
Posts: 1843
Location: US

Post Reply with quote
I noticed that you can use (simple) html WITHOUT quotes.. so you can use this same code for random images.. I used it on www.scodal.com

Use something like this in each line used for the random slogan:
Code:
<img border=0 src=URL.jpg>


That's all!

_________________
www.scottdizzle.com uses cnr Smile
last update: 07-22-08: 8:30 pm
Sun Oct 28, 2007 3:23 am View user's profile Send private message Visit poster's website AIM Address
Display posts from previous:    
Reply to topic    Forum Index » Skins and snippets All times are GMT + 1 Hour
Page 1 of 1

 
Jump to: 
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You cannot attach files in this forum
You cannot download files in this forum



Powered by phpBB © 2001, 2005 phpBB Group
Design by Freestyle XL / Music Lyrics.