Log inUsernamePassword
Log me on automatically each visit    
Register
Register
Log in to check your private messages
Log in to check your private messages
CJ Webmaster Forums Forum Index -> PHP Scripts » CJ Random Quote

   
different set of quotes on each page
View previous topic :: View next topic  
Author Message
maxbato



Joined: 10 Oct 2005
Posts: 1

Posted: Mon Oct 10, 2005 1:24 am    Post subject: different set of quotes on each page

Hello,

Great little script here. Is it possible for me to have a different set of quotes on each page of my site?

Any one know if it I can easlily modify it to allow this?

Thanks for your time

Max
Back to top
GodfatherUK
CJ-Design.com Moderator



Joined: 17 Sep 2004
Posts: 206
Location: UK

Posted: Mon Oct 10, 2005 1:51 pm    Post subject:

You could easily just make a second file.

So make a copy of randomquote.php as something like randomquote2.php

Then also create 2 more .inc files and link correctly to them in the new .php file. And dont forget to set the correct permissions (777)

Then simply link to the new file.

Although if you have loads of pages, this is a load of work and a load of files.

If you are talking 20 odd pages, maybe you could try the following,

Create 5 of the files as i get at above.

Place the following at the top of each page (or in a config file if you have linked to one in your pages)

Code:

srand((double)microtime()*1000000);
$showquote = rand(0,5);


Then where you want to place the random quote, simply include as follows:

Code:
<?php
include "randomquote/$showquote.php";
?>


This doesnt give you a different set of quotes for each page, but means that each time the page is loaded, it will draw its quote from one of the 5 files.. Which really opens you up for LOADS of quotes ..

Hope this maybe helps a little
_________________
GodfatherUK
CJ Designs Forum Moderator

"I dont think i am good at coding.. But i KNOW im good at helping"


Last edited by GodfatherUK on Mon Oct 10, 2005 4:24 pm; edited 1 time in total
Back to top
GodfatherUK
CJ-Design.com Moderator



Joined: 17 Sep 2004
Posts: 206
Location: UK

Posted: Mon Oct 10, 2005 4:23 pm    Post subject:

After reviewing what i have posted one word came to mind ... "D'oh!"

I have just told you to create loads of copies of the randomquote.php instead of the simple way of making it bring from a random set of quotes.

Open randomquote.php

Find
Code:
$directory = "http://www.domain.com/randomquote/";      //  Webserver path to your quote files with / on end!


Add, after
Code:

srand((double)microtime()*1000000);    // DONT Edit This!
$showquote = rand(0,5);
// Edit the 5 to however many different sets of quotes you have!


Then change
Code:
$quotefile = "randomquote.inc";

to
Code:
$quotefile = $showquote . ".inc";


You will then basically need to change your randomquote.inc file to 1.inc and any others you make to 2.inc 3.inc etc

Hope this works and helps
_________________
GodfatherUK
CJ Designs Forum Moderator

"I dont think i am good at coding.. But i KNOW im good at helping"
Back to top
Display posts from previous:   
       CJ Webmaster Forums Forum Index -> PHP Scripts » CJ Random Quote All times are GMT
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

Powered by phpBB © 2001, 2002 phpBB Group
iCGstation v1.0 Template By Ray © 2003, 2004 iOptional, Mods by CJ Website Design