How can you pull a random item and leave that item on site for a specified time period?
How can you pull a random item and leave that item on site for a specified time period?
am 01.10.2007 19:19:48 von itcassy
I would like to pull a random or alphabetical result on the home page
of a site and leave that same result on there for one week. The
closest example I have found online is Random Quote Version 3.1 which
pulls from a text file rather than the database. I cannot mod it to
pull from my db and also it relies on cookies, so I would assume it
would pull a different random item for each computer and then keep
that item on the page for whatever time you specify (?). I am working
with dealers and would like to automatically feature a different
dealer every week without having to go into the db and choose which
one to feature. Is this possible using PHP and MySQL? Does anyone have
any suggestions on a different technology or maybe some links to help?
Re: How can you pull a random item and leave that item on site for a specified time period?
am 01.10.2007 19:47:54 von Hans-Peter Sauer
<1191259188.218679.86660@g4g2000hsf.googlegroups.com>
> I would like to pull a random or alphabetical result on the home page
> of a site and leave that same result on there for one week. The
> closest example I have found online is Random Quote Version 3.1 which
> pulls from a text file rather than the database. I cannot mod it to
> pull from my db and also it relies on cookies, so I would assume it
> would pull a different random item for each computer and then keep
> that item on the page for whatever time you specify (?). I am working
> with dealers and would like to automatically feature a different
> dealer every week without having to go into the db and choose which
> one to feature.
>
$temp=time()+604800;
# the above is TIME NOW plus one week
# save $temp to database or flat file
?>
# grab $temp from database or flat file
$rambo=time();
if ($rambo>$temp) {print "One week has passed - select another dealer";}
?>
--
www.vhit.co.uk
Re: How can you pull a random item and leave that item on site for a specified time period?
am 01.10.2007 19:56:53 von itcassy
On Oct 1, 1:47 pm, Krustov wrote:
>
>
>
> <1191259188.218679.86...@g4g2000hsf.googlegroups.com>
>
> > I would like to pull a random or alphabetical result on the home page
> > of a site and leave that same result on there for one week. The
> > closest example I have found online is Random Quote Version 3.1 which
> > pulls from a text file rather than the database. I cannot mod it to
> > pull from my db and also it relies on cookies, so I would assume it
> > would pull a different random item for each computer and then keep
> > that item on the page for whatever time you specify (?). I am working
> > with dealers and would like to automatically feature a different
> > dealer every week without having to go into the db and choose which
> > one to feature.
>
>
>
> $temp=time()+604800;
>
> # the above is TIME NOW plus one week
>
> # save $temp to database or flat file
>
> ?>
>
>
>
> # grab $temp from database or flat file
>
> $rambo=time();
>
> if ($rambo>$temp) {print "One week has passed - select another dealer";}
>
> ?>
>
> --www.vhit.co.uk
Thanks for the quick response! However, I am not sure this will work.
Maybe I can clarify... I want the page to automatically choose a
different dealer to display automatically every week. Just like a
random sort except not every time you load the page, I only want the
code to choose a new dealer every week. If I save the temp time to
the db, it would only work once (?) for the first week? Please
correct me if I am not following....
Re: How can you pull a random item and leave that item on site for a specified time period?
am 01.10.2007 20:12:34 von Hans-Peter Sauer
<1191261413.250677.48280@d55g2000hsg.googlegroups.com>
> Thanks for the quick response! However, I am not sure this will work.
> Maybe I can clarify... I want the page to automatically choose a
> different dealer to display automatically every week. Just like a
> random sort except not every time you load the page, I only want the
> code to choose a new dealer every week. If I save the temp time to
> the db, it would only work once (?) for the first week? Please
> correct me if I am not following....
>
Yes i know what you want - but theres no way for anybody but yourself to
know how much or how little php skills you have - some people only need
a pointer and some people need more help .
At the end of the week - just repeat the $temp process to pick another
dealer to be shown - then repeat again the next week etc .
Assuming you have 50 dealers .....
$batman=(rand()%50);
This will pick a number between 0-49
If dealer number 22 is picked then store dealers name No. 22 in the
database or a flat file .
Then retrieve the dealers name from the database or flat file anytime
the index.php is loaded - and anytime it does this - then check the
$temp to see if its older than one week old .
--
www.vhit.co.uk
Re: How can you pull a random item and leave that item on site for a specified time period?
am 01.10.2007 21:00:36 von Paul Herber
On Mon, 1 Oct 2007 18:47:54 +0100, Krustov wrote:
>
>
>
><1191259188.218679.86660@g4g2000hsf.googlegroups.com>
>
>> I would like to pull a random or alphabetical result on the home page
>> of a site and leave that same result on there for one week. The
>> closest example I have found online is Random Quote Version 3.1 which
>> pulls from a text file rather than the database. I cannot mod it to
>> pull from my db and also it relies on cookies, so I would assume it
>> would pull a different random item for each computer and then keep
>> that item on the page for whatever time you specify (?). I am working
>> with dealers and would like to automatically feature a different
>> dealer every week without having to go into the db and choose which
>> one to feature.
>>
>
>
>
>$temp=time()+604800;
>
># the above is TIME NOW plus one week
>
># save $temp to database or flat file
>
>?>
>
>
>
># grab $temp from database or flat file
>
>$rambo=time();
>
>if ($rambo>$temp) {print "One week has passed - select another dealer";}
>
>?>
Whatever you do, do not follow Krusty's variable naming style.
--
Regards, Paul Herber, Sandrila Ltd. http://www.sandrila.co.uk/