Re: [PHP] Banner rotation with links

2007-02-15 Thread Edward Vermillion


On Feb 15, 2007, at 10:57 AM, Jochem Maas wrote:


Kevin Murphy wrote:
On my home page i have all my banners in a MySQL database which  
includes

the image path, the link, and the description as separate fields. The
then do a MySQL query with a query that will look something like  
this:


$query = "select * FROM banner ORDER BY RAND() LIMIT 1";

Seems to work just fine.


just wait till you have 10 items in that table :-)
in practice that may never happen and maybe MySQL can optimize a
SELECT that does "ORDER BY RAND() LIMIT 1"

(can anyone confirm what MySQL does with "ORDER BY RAND() LIMIT 1"  
exactly in terms
of scanning the table? - the MySQL docs don't mention whether this  
is scalable at all)




Apparently a lot of folks think it's a bad idea on large tables...

http://www.google.com/search?client=safari&rls=en&q=ORDER+BY+RAND 
();&ie=UTF-8&oe=UTF-8


--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] Banner rotation with links

2007-02-15 Thread Jochem Maas
Kevin Murphy wrote:
> On my home page i have all my banners in a MySQL database which includes
> the image path, the link, and the description as separate fields. The
> then do a MySQL query with a query that will look something like this:
> 
> $query = "select * FROM banner ORDER BY RAND() LIMIT 1";
> 
> Seems to work just fine.

just wait till you have 10 items in that table :-)
in practice that may never happen and maybe MySQL can optimize a
SELECT that does "ORDER BY RAND() LIMIT 1"

(can anyone confirm what MySQL does with "ORDER BY RAND() LIMIT 1" exactly in 
terms
of scanning the table? - the MySQL docs don't mention whether this is scalable 
at all)

*but* if that is not the case then using a field (call it 'randomized' or 
something like that)
and indexing on that and then updating that field periodically with random
integers using a cronjob script would make the resulting query alot more robust 
..
the compromise being that you don't get a different banner each request:

$query = "select * FROM banner ORDER BY randomized LIMIT 1";

the compromise can be mitigated some what by doing something like this
(assuming you use sessions):

// BRC = Banner Random Count
if (!isset($_SESSION['BRC']))
$_SESSION['BRC'] = 0;
$query = "select * FROM banner ORDER BY randomized LIMIT {$_SESSION['BRC']},1";
$_SESSION['BRC']++;

> 
> --Kevin Murphy
> Webmaster: Information and Marketing Services
> Western Nevada Community College
> www.wncc.edu
> 775-445-3326
> 
> 
> On Feb 14, 2007, at 8:29 AM, Chris Carter wrote:
> 
>>
>> How can I rotate a banner as well as the link in it within a page
>> using PHP.
>> This can be done as a include file php. Anybody please supply some
>> code or a
>> link for this.
>>
>> Thanks in advance.
>>
>> Chris
>> --View this message in context:
>> http://www.nabble.com/Banner-rotation-with-links-tf3228157.html#a8968148
>> Sent from the PHP - General mailing list archive at Nabble.com.
>>
>> --PHP General Mailing List (http://www.php.net/)
>> To unsubscribe, visit: http://www.php.net/unsub.php
>>
> 
> 

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] Banner rotation with links

2007-02-15 Thread Kevin Murphy
On my home page i have all my banners in a MySQL database which  
includes the image path, the link, and the description as separate  
fields. The then do a MySQL query with a query that will look  
something like this:


$query = "select * FROM banner ORDER BY RAND() LIMIT 1";

Seems to work just fine.

--
Kevin Murphy
Webmaster: Information and Marketing Services
Western Nevada Community College
www.wncc.edu
775-445-3326


On Feb 14, 2007, at 8:29 AM, Chris Carter wrote:



How can I rotate a banner as well as the link in it within a page  
using PHP.
This can be done as a include file php. Anybody please supply some  
code or a

link for this.

Thanks in advance.

Chris
--
View this message in context: http://www.nabble.com/Banner-rotation- 
with-links-tf3228157.html#a8968148

Sent from the PHP - General mailing list archive at Nabble.com.

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php





RE: [PHP] Banner rotation with links

2007-02-14 Thread Tim
 

> -Message d'origine-
> De : Brad Fuller [mailto:[EMAIL PROTECTED] 
> Envoyé : mercredi 14 février 2007 17:41
> À : 'Németh Zoltán'; 'Chris Carter'
> Cc : php-general@lists.php.net
> Objet : RE: [PHP] Banner rotation with links
> 
> > -Original Message-
> > From: Németh Zoltán [mailto:[EMAIL PROTECTED]
> > Sent: Wednesday, February 14, 2007 11:37 AM
> > To: Chris Carter
> > Cc: php-general@lists.php.net
> > Subject: Re: [PHP] Banner rotation with links
> > 
> > 2007. 02. 14, szerda keltezéssel 08.29-kor Chris Carter ezt írta:
> > > How can I rotate a banner as well as the link in it within a page 
> > > using
> > PHP.
> > > This can be done as a include file php. Anybody please 
> supply some 
> > > code
> > or a
> > > link for this.
> > 
> > please go STFW for "banner rotation php script"
> > 
> > greets
> > Zoltán Németh
> > 
> 
> Even better, download this free open source application which 
> does it all for you...
> 
> http://www.phpadsnew.com/
> 
> -Brad
Yeah, maybe their should be an alternate list for "Where can i find the app
for me to do this" queries :D

Regards,

Tim

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



RE: [PHP] Banner rotation with links

2007-02-14 Thread Brad Fuller
> -Original Message-
> From: Németh Zoltán [mailto:[EMAIL PROTECTED]
> Sent: Wednesday, February 14, 2007 11:37 AM
> To: Chris Carter
> Cc: php-general@lists.php.net
> Subject: Re: [PHP] Banner rotation with links
> 
> 2007. 02. 14, szerda keltezéssel 08.29-kor Chris Carter ezt írta:
> > How can I rotate a banner as well as the link in it within a page using
> PHP.
> > This can be done as a include file php. Anybody please supply some code
> or a
> > link for this.
> 
> please go STFW for "banner rotation php script"
> 
> greets
> Zoltán Németh
> 

Even better, download this free open source application which does it all
for you...

http://www.phpadsnew.com/

-Brad

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



RE: [PHP] Banner rotation with links

2007-02-14 Thread Tim
 

> -Message d'origine-
> De : Chris Carter [mailto:[EMAIL PROTECTED] 
> Envoyé : mercredi 14 février 2007 17:29
> À : php-general@lists.php.net
> Objet : [PHP] Banner rotation with links
> 
> 
> How can I rotate a banner as well as the link in it within a 
> page using PHP.
> This can be done as a include file php. Anybody please supply 
> some code or a link for this.
> 
> Thanks in advance.

Hi depends on "what moment you are changing the banner" if you are doing it
on a page change you can do this with PHP by querying a DB for a random
banner (or non random thats up to you to decide) entry to display, each time
you load the page.

If you are wanting to do the "banner change" based on a time interval you
would have to setup some javascript to do this for you, maybe generate it
using php that formerly queried a database of banner entries.

Google: banners +javascript first before posting, there's always an answer
;)

Regards,

Tim

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] Banner rotation with links

2007-02-14 Thread Németh Zoltán
2007. 02. 14, szerda keltezéssel 08.29-kor Chris Carter ezt írta:
> How can I rotate a banner as well as the link in it within a page using PHP.
> This can be done as a include file php. Anybody please supply some code or a
> link for this.

please go STFW for "banner rotation php script"

greets
Zoltán Németh

> 
> Thanks in advance.
> 
> Chris
> -- 
> View this message in context: 
> http://www.nabble.com/Banner-rotation-with-links-tf3228157.html#a8968148
> Sent from the PHP - General mailing list archive at Nabble.com.
> 

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php