 |
 |
 |
 |
 |
| Author |
Message |
scottdallas

Joined: 04 May 2006 Posts: 1843 Location: US |
|
Random Slogan Code |
|
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.
 |  | <?
$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
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 |
|
 |
Guest
|
|
|
Please login to hide the ads.
|
|
|
|
 |
scottdallas

Joined: 04 May 2006 Posts: 1843 Location: US |
|
|
|
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
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 |
|
 |
Ramon
Joined: 12 Oct 2005 Posts: 462 Location: Hoogeveen, NL |
|
|
|
Huhu _O_
Try this scott
 |  | <?
$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 |
|
 |
scottdallas

Joined: 04 May 2006 Posts: 1843 Location: US |
|
|
|
Is $random_text used in cutenews.ru? I figured it must be. I didn't try the code yet
_________________ www.scottdizzle.com uses cnr
last update: 07-22-08: 8:30 pm |
|
| Sun May 06, 2007 6:53 am |
|
 |
FI-DD
Admin

Joined: 22 Sep 2005 Posts: 2736 Location: Germany |
|
|
|
I think $random is used in the other random news hack.
|
|
| Wed May 09, 2007 5:46 pm |
|
 |
scottdallas

Joined: 04 May 2006 Posts: 1843 Location: US |
|
|
|
Thanks guys I fixed the code and updated it above after testing it. Works fine.
_________________ www.scottdizzle.com uses cnr
last update: 07-22-08: 8:30 pm |
|
| Thu May 10, 2007 9:57 pm |
|
 |
scottdallas

Joined: 04 May 2006 Posts: 1843 Location: US |
|
|
|
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:
 |  | <img border=0 src=URL.jpg> |
That's all!
_________________ www.scottdizzle.com uses cnr
last update: 07-22-08: 8:30 pm |
|
| Sun Oct 28, 2007 3:23 am |
|
 |
|
|
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
|
|
 |
 |
 |
|