Register | Login
Views: 19364387
Main | Memberlist | Active users | ACS | Commons | Calendar | Online users
Ranks | FAQ | Color Chart | Photo album | IRC Chat
11-02-05 12:59 PM
0 user currently in Programming. | 3 guests
Acmlm's Board - I2 Archive - Programming - Random quote generator | |
Add to favorites | "RSS" Feed | Next newer thread | Next older thread
User Post
Lord Rahl

Snap Dragon
Level: 43

Posts: 88/792
EXP: 544657
For next: 20389

Since: 03-15-04
From: Temple of the Winds - Training Room

Since last post: 43 days
Last activity: 7 days
Posted on 03-25-04 06:46 AM Link | Quote
Once on the Soul Angel message board, the head admin, Ogre, had a random picture generator in his layout. It would randomly pick a picture from a collection he had online and place that pic in his layout. Any time the page was refreshed, the pic would change.

Anyway, seeing as that board has been reset since he last used that layout, I was wondering if anyone could help me set up something like that, for quotes, to use on this board?

I would like it for the layout I'm planning on putting together.
FreeDOS

Lava Lotus
Wannabe-Mod :<
Level: 59

Posts: 244/1657
EXP: 1648646
For next: 24482

Since: 03-15-04
From: Seattle

Since last post: 6 hours
Last activity: 4 hours
Posted on 03-25-04 10:25 AM Link | Quote
I have one for pulling out random images...

http://mike.gamingvortex.net/images/randimg.phps

Basically:
1. Make new directory.
2. Add images to that directory.
3. Change PHP script to look in that directory (here: $handle = opendir('test'); | and here: $img = fopen("./test/$picture", "r");)

Make sure the extensions are the same as the MIME content type. As long as it's PNG, GIF, and JPG, you're fine.
Lord Rahl

Snap Dragon
Level: 43

Posts: 93/792
EXP: 544657
For next: 20389

Since: 03-15-04
From: Temple of the Winds - Training Room

Since last post: 43 days
Last activity: 7 days
Posted on 03-25-04 11:52 AM Link | Quote
Would you have any idea how to change it so that it would do text instead of pictures?

EDIT: Short of putting my quote list into a collection of pictures, of course.


(edited by Lord Rahl on 03-25-04 02:54 AM)
Kenny3900
Newcomer
Level: 6

Posts: 8/9
EXP: 659
For next: 248

Since: 03-15-04

Since last post: 576 days
Last activity: 339 days
Posted on 03-25-04 12:24 PM Link | Quote
JavaScript can do that already

(Text before)

// Put inside <script>
var theQuotes = new Array(Number of quotes);
theQuotes[0] = "Quote #1";
...
theQuotes[Number of quotes - 1] = "Quote #n";
document.write(theQuotes[Math.round(Math.random() * Number of quotes -.5)]);
// </script>

(Text after)
Wrath

Shyguy
Level: 17

Posts: 11/93
EXP: 21856
For next: 2887

Since: 03-18-04
From: Canada

Since last post: 547 days
Last activity: 339 days
Posted on 03-25-04 02:57 PM Link | Quote
You could also do it using php, but I would only do it this way if youi are going to use a few images because the code will get pretty big if there is alot of images

$rannum=mt_rand(1,10);

if($rannum=='1'){$banner="<img src=imageurl>";}
if($rannum=='2'){$banner="<img src=imageurl>";}
if($rannum=='3'){$banner="<img src=imageurl>";}
if($rannum=='4'){$banner="<img src=imageurl>";}
if($rannum=='5'){$banner="<img src=imageurl>";}
if($rannum=='6'){$banner="<img src=imageurl>";}
if($rannum=='7'){$banner="<img src=imageurl>";}
if($rannum=='8'){$banner="<img src=imageurl>";}
if($rannum=='9'){$banner="<img src=imageurl>";}
if($rannum=='10'){$banner="<img src=imageurl>";}


Edit the coding for your own preferences and use the variable $banner to display the image








(edited by Wrath on 03-25-04 05:57 AM)
(edited by Wrath on 03-25-04 05:58 AM)
kiwibonga

Double metal axe
Level: 27

Posts: 26/266
EXP: 106040
For next: 10119

Since: 03-15-04
From: Montreal, QC, Canada

Since last post: 126 days
Last activity: 3 days
Posted on 03-25-04 03:41 PM Link | Quote
something even simpler and dumber:

randimg.php:

<?php

$NUMIMG=put number of images here;

$myrandomnumber = rand(1,$NUMIMG);

switch($myrandomnumber) {

case 1:
header("/images/myrandomimage1.jpg");
break;

case 2:
header("/images/myrandomimage2.jpg");
break;

etc.....

}

?>

it'll just force a redirect to an image automatically.

Oh and since javascript isn't allowed here there's only one way to show random quotes: using images, or asking acmlm to host the random quote script and add a special && tag (right, right)
Lord Rahl

Snap Dragon
Level: 43

Posts: 100/792
EXP: 544657
For next: 20389

Since: 03-15-04
From: Temple of the Winds - Training Room

Since last post: 43 days
Last activity: 7 days
Posted on 03-25-04 10:23 PM Link | Quote
I'll ask Acmlm then, considering I was hoping on using most of my quote list, and I have over one hundred quotes, easy.

EDIT: Or I could just change them by hand, but that kind of defeats what I was hoping of doing.


(edited by Lord Rahl on 03-25-04 01:28 PM)
Acmlm

Torosu
heh
Level: 51

Posts: 366/1173
EXP: 981994
For next: 31944

Since: 03-15-04
From: Somewhere that isn't outside of Sherbrooke, Québec, Canada

Since last post: 39 days
Last activity: 3 hours
Posted on 03-26-04 09:40 AM Link | Quote
Hmm ... adding a &____& that shows a random quote would be possible, but you wouldn't be able to customize it

What I'd do is a PHP script that picks a random quote (in text), then outputs an image with that text ... not hard when you know how to use the GD library functions
Jesper
Busy, busy, busy.
Level: 69

Posts: 130/2390
EXP: 2856000
For next: 13743

Since: 03-15-04
From: Sweden.

Since last post: 176 days
Last activity: 79 days
Posted on 03-26-04 01:27 PM Link | Quote
I could be able to set such a contraption up. I already have a login system to change the wootest titles. I'll look into it.
Lord Rahl

Snap Dragon
Level: 43

Posts: 124/792
EXP: 544657
For next: 20389

Since: 03-15-04
From: Temple of the Winds - Training Room

Since last post: 43 days
Last activity: 7 days
Posted on 03-28-04 05:57 AM Link | Quote
Thank you both. I'd try to set it up myself, but know nothing of Javascript or PHP, although I would like to learn both. School doesn't offer them, though.
Add to favorites | "RSS" Feed | Next newer thread | Next older thread
Acmlm's Board - I2 Archive - Programming - Random quote generator | |


ABII


AcmlmBoard vl.ol (11-01-05)
© 2000-2005 Acmlm, Emuz, et al



Page rendered in 0.015 seconds.