Being as I've been helped here before, I thought I'd pop back with yet another dilemma!
There is a site that i'm involved with, that has a list of adverts in a block on the home page.
As new sponsors come onboard, they get added to the bottom of the list.
Now some of these have (rightly so) shown a discomfort in paying to have an advert on the bottom of the page, so now what I wan't to do is have these images displayed randomly on page load.
All the images are stored in various formats in the same folder
../images/advertising
the current block: block-advertising.php has the following code
Code:
<?php
if (eregi('block-adverts.php', $_SERVER['PHP_SELF'])) {
Header('Location: index.php');
die();
}
$content .= "</center>";
$content .= "<br>";
$content .= "<p><font size=\"10\"> Interested in becoming a sponsor? click <a href=\"http://bkksys.co.uk/modules.php?name=Advertising\">HERE</a>.</p></font>";
?>
As you can see, my code is probably very crude and amaturish(f7)?
Any ideas how I can either alter the block, or create a new one to display the images in a new order on each page load?
I'd also like it fairly easily editable, so as new sponsors arrive, I can add them.
Thanks in advance - Any help / advice greatly appreciated!
Chris.
P.S I'm not sure if this makes any difference, but the society involved is a non profit society. Just didn't want to think I was trying to make money from your help:-)
If you use the built-in features of the banners script or Advertising (in newer phpNukes), you will get randomization essentially for free. No messing with any HTML or PHP code
Ah that will be a different issue. I think you can still use the banner tables to store the ads. But need to write some code to generate the random order. You could do it using an "ORDER BY RAND()" SQL statement
//No need to edit below this line...
if ($show_credit) {
$randimg[count($randimg)+1] = array(
"http://www.codezwiz.com/", //Link
"http://www.codezwiz.com/images/links/codezwiz12.gif", //Image
"Codezwiz >> PHP Nuke themes and scripts development and support", //image alt (mouseover text)
"392", //image width
"72" //image height
);
}
srand((double)microtime()*1000000);
$res = array();
$n = count($randimg);
for ($i=0;$i<$n;$i++) {
$res[$i] = 0;
}
for ($i=0;$i<$n;$i++) {
do {
$rv = rand(0, $n);
$ban = 0;
for ($j=0;$j<$n;$j++) {
if ($res[$j] == $rv) {
$ban = 1;
break;
View next topic View previous topic
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