Re: Re: note 8165 added to rand
| From: | JINGLE BALLS | Date: | Tue, 29 Aug 2000 20:53:43 +0000 |
| Subject: | Re: Re: note 8165 added to rand | ||
| References: | 1 2 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-14235@lists.php.net to get a copy of this message | ||
it aint that pretty, but it works, you can change the DB calls to files and
add a static array if you want
<?php
$stmt = "SELECT * FROM banner where run = '1'";
$result = mysql_db_query($DB, $stmt);
$rows = mysql_num_rows(mysql_db_query($DB, $stmt));
for ($banid = 1; $banid <= $rows; $banid++) {
$rowarray = mysql_fetch_row($result);
$banarray[$banid] = $rowarray[0];
}
srand((double)microtime()*1000000);
shuffle($banarray);
$td = "<td width=\"50%\"> ";
$tde = " </td> \n";
$tr = "<tr> \n";
$tre = "</tr> \n";
$table = "<table class = \"";
$tablep = "\" border=\"0\" width=\"100%\"
bgcolor=\"#FFFFFF\"> \n";
$tablee = "</table> \n";
for ($banid = 0; $banid <= $rows-1; $banid++) {
$rowcount = $banid;
$colcount = $colcount + 1;
if ($rowcount == 0) {
echo("$table"."sw"."$tablep");
}
if ($colcount == 2) {
echo ("$td");
echo ("<!-- $banarray[$banid] -- $banid -->");
require "banner/$banarray[$banid]";
echo ("$tde");
echo("$tre");
$colcount = 0;
} else {
echo("$tr");
echo ("$td");
echo ("<!-- $banarray[$banid] -- $banid -->");
require "banner/$banarray[$banid]";
echo ("$tde");
}
}
if ($colcount == 1) { echo("$tre"); }
echo ("$tablee");
?>
this puts a ton of banners on my site within a table...www.geekxmail.com
--
Chris McKeever
cgmckeever@norphans.com
773.443.7932 - direct line
Norphans.Com, A Division of The Norphan Company
WWW.Norphans.com
877-NORPHAN
"Zak Greant" <zak@nucleus.com> wrote in message
news:4.3.2.7.0.20000829143504.02011360@mail.nucleus.com...
> At 08:26 PM 8/29/00 +0000, markmh84@hotmail.com wrote:
> >How can I create a random banner ad generator?
> >
> ><?
> >rand();
> >ad('<a href=""><img src=""></a>';
> > '<a href=""><img src=""></a>';
> > '<a href=""><img src=""></a>';
> > '<a href=""><img src=""></a>');
> >
> >?>
> >
> >then when i want to call the banner i use <? echo = $banner; ?> or
> >something to display it.
> >
> >I'm new to php, so please write me the entire code, thanx!
>
> The manual notes are not the place for asking support questions. Before
> posting another note, please make sure to read the instructions at
> http://www.php.net/manual/add-note.php
>
> I have cc'd this email to the php-general support list. Someone there
> should be able to help you out. You can subscribe to this list by sending
> mail to php-general-subscribe@lists.php.net.
>
> Good Luck!
>
> - Zak
>
>
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, e-mail: php-general-unsubscribe@lists.php.net
> For additional commands, e-mail: php-general-help@lists.php.net
> To contact the list administrators, e-mail: php-list-admin@lists.php.net
>