PHP Web Host - Quality Web Hosting For All PHP Applications Free RavenNuke(tm) Add Ons
  Login or Register
 • Home • Downloads • Your Account • Forums • 

View next topic
View previous topic


Google
 
Web RavenPHPScripts (This Site)
Post new topic   Reply to topic
Author Message
Maclain
Regular
Regular


Joined: Feb 25, 2006
Posts: 60
Location: England

PostPosted: Tue Nov 25, 2008 2:05 am Reply with quote Back to top

OK.

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 .= "<p><a href=\"http://yorkshirekoi.co.uk/_launch.php?id=170\" target=\"_blank\"><img src=\"/images/advertising/mholmesmain11-07.jpg\"></a></p>";
$content .= "<br>";
$content .= "<p><a href=\"http://www.selectivekoisales.co.uk/\" target=\"_blank\"><img src=\"/images/advertising/SELECTIVEKOI11-07.jpg\"></a></p>";
$content .= "<br>";
$content .= "<p><a href=\"http://www.absolute-koi.com\" target=\"_blank\"><img src=\"/images/0308.gif\"></a></p>";
$content .= "<br>";
$content .= "<p><a href=\"http://bkksys.co.uk\" target=\"_blank\"><img src=\"/images/advertising/koimastersbanner.jpg\"></a></p>";
$content .= "<br>";
$content .= "<p><a href=\"http://www.koiplus.com\" target=\"_blank\"><img src=\"/images/koiplus140408.JPG\"></a></p>";
$content .= "<p><a href=\"http://www.shingoi.com/\" target=\"_blank\"><img src=\"/images/advertising/shingoi1.gif\"></a></p>";
$content .= "<p><a href=\"http://www.jammyfoldkoi.com/\" target=\"_blank\"><img src=\"/images/advertising/jammy.gif\"></a></p>";
$content .= "<p><a href=\"http://www.lambournkoi.co.uk/\" target=\"_blank\"><img src=\"/images/advertising/lambourn.jpg\"></a></p>";
$content .= "<p><a href=\"http://www.shingoi.com/\" target=\"_blank\"><img src=\"/images/advertising/shingoi2.gif\"></a></p>";
$content .= "<p><a href=\"http://www.yourkoi.co.uk/\" target=\"_blank\"><img src=\"/images/advertising/yourkoi.gif\"></a></p>";
$content .= "<p><a href=\"http://www.migoto-koi.co.uk/\" target=\"_blank\" width=\"548\" height=\"92\"><img src=\"/images/advertising/migotokoi.JPG\"></a></p>";
$content .= "<p><a href=\"http://www.koi-uk.co.uk/\" target=\"_blank\" width=\"548\" height=\"92\"><img src=\"/images/advertising/koiuk.png\"></a></p>";
$content .= "<p><a href=\"http://www.pastureslodge.co.uk/\" target=\"_blank\" width=\"548\" height=\"92\"><img src=\"/images/advertising/pastures.png\"></a></p>";
$content .= "<p><a href=\"http://www.richdon-koi.com/\" target=\"_blank\" width=\"548\" height=\"92\"><img src=\"/images/advertising/richdon.gif\"></a></p>";
$content .= "<p><a href=\"http://www.koicarp.org.uk/\" target=\"_blank\" width=\"548\" height=\"92\"><img src=\"/images/advertising/koiwater.jpg\"></a></p>";
$content .= "<p><a href=\"http://www.uknishikigoi.com/\" target=\"_blank\" width=\"548\" height=\"92\"><img src=\"/images/advertising/uknishi.gif\"></a></p>";
$content .= "<p><a href=\"http://www.cicscreens.co.uk/\" target=\"_blank\" width=\"548\" height=\"92\"><img src=\"/images/advertising/cicscreens.jpg\"></a></p>";

$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:-)
View user's profile Send private message Visit poster's website
evaders99
Former Moderator in Good Standing


Joined: Apr 30, 2004
Posts: 3221

PostPosted: Tue Nov 25, 2008 2:10 am Reply with quote Back to top

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
View user's profile Send private message Visit poster's website
Maclain
Regular
Regular


Joined: Feb 25, 2006
Posts: 60
Location: England

PostPosted: Tue Nov 25, 2008 2:26 am Reply with quote Back to top

I;ve played about with it as I use it on another site.

The only problem is it only displays one advert. I need to display all of them at once on the page....
View user's profile Send private message Visit poster's website
evaders99
Former Moderator in Good Standing


Joined: Apr 30, 2004
Posts: 3221

PostPosted: Tue Nov 25, 2008 12:00 pm Reply with quote Back to top

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
View user's profile Send private message Visit poster's website
Maclain
Regular
Regular


Joined: Feb 25, 2006
Posts: 60
Location: England

PostPosted: Wed Nov 26, 2008 3:06 am Reply with quote Back to top

Sounds interesting...

None of the images are stored in the tables at the moment, but that's easily sorted.

As for the sql code and php block code involved in getting it to display correctly, well I wouldn't have a scooby doo.

I'd be willing to attempt to write the block though, if your willing to help / guide me along the way?

TIA!
View user's profile Send private message Visit poster's website
Maclain
Regular
Regular


Joined: Feb 25, 2006
Posts: 60
Location: England

PostPosted: Sat Nov 29, 2008 7:21 am Reply with quote Back to top

sorted elsewhere. Ta.
View user's profile Send private message Visit poster's website
Guardian2003
Site Admin


Joined: Aug 28, 2003
Posts: 6373
Location: Vsetin, Czech Republic

PostPosted: Sat Nov 29, 2008 1:12 pm Reply with quote Back to top

Did you want to share the code in case it helps anyone else?
View user's profile Send private message Send e-mail Visit poster's website
Maclain
Regular
Regular


Joined: Feb 25, 2006
Posts: 60
Location: England

PostPosted: Mon Dec 01, 2008 3:41 am Reply with quote Back to top

Sorry!

That would be a good idea

Code:

<?php
/*******************************
   Random Image block
   Codezwiz Network, LLC.
   http://www.codezwiz.com/
   © 2002-2009
********************************/

if (eregi('block-adverts.php', $_SERVER['PHP_SELF'])) {
    Header('Location: index.php');
    die();
}

$show_credit = 1;
$content = "";

$randimg = array();

//Add one of these $randimg[NUMBER] array for each image.
//Add as many as you like but be sure to increment the array $randimg[1], $randimg[2], etc.

$randimg[1] = array(
   "http://yorkshirekoi.co.uk/_launch.php?id=170", //Link
    "/images/advertising/mholmesmain11-07.jpg", //Image
   "", //image alt (mouseover text)
   "", //image width
   "" //image height
);
$randimg[2] = array(
   "http://www.selectivekoisales.co.uk/", //Link
    "/images/advertising/SELECTIVEKOI11-07.jpg", //Image
   "", //image alt (mouseover text)
   "", //image width
   "" //image height
);
$randimg[3] = array(
   "http://www.absolute-koi.com/", //Link
    "/images/0308.gif", //Image
   "", //image alt (mouseover text)
   "", //image width
   "" //image height
);
$randimg[4] = array(
   "http://bkksys.co.uk/", //Link
    "/images/advertising/koimastersbanner.jpg", //Image
   "", //image alt (mouseover text)
   "", //image width
   "" //image height
);



//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;

         }
          }
   }
   while($ban == 1);
       $res[$i] = $rv;
}
for ($i=0;$i<$n;$i++) {
   $alt = ($randimg[$res[$i]][2] != "") ? " title=\"".$randimg[$res[$i]][2]."\"" : " title=\"".$randimg[$res[$i]][0]."\"";
   $width = ($randimg[$res[$i]][3] > 0) ? " width=\"".$randimg[$res[$i]][3]."\"" : "";
   $height = ($randimg[$res[$i]][4] > 0) ? " height=\"".$randimg[$res[$i]][4]."\"" : "";
   $content .= "<center><p><a href=\"".$randimg[$res[$i]][0]."\" target=\"_blank\"><img border=\"0\" src=\"".$randimg[$res[$i]][1]."\"".$width."".$height."".$alt." /></center></a></p><br />\n";
}

$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>.</font></p>\n";
?>
View user's profile Send private message Visit poster's website
Display posts from previous:       
Post new topic   Reply to topic

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
Forums ©
 

All logos and trademarks in this site are property of their respective owner.
The comments are property of their posters, all the rest © 2002-2011 by Raven

You can syndicate our news using the file xml

CSE HTML Validator Helped Clean up This Page! [Valid RSS] valid RSS 2.0 Valid robots.txt Stop Spam Harvesters, Join Project Honey Pot

Website engines core code is © copyright by PHP-Nuke but has been heavily patched and modified by myself and others.
PHP-Nuke is a free software released under the GNU/GPL.


:: fisubice phpbb2 style by Daz :: PHP-Nuke theme by www.nukemods.com ::
:: fisubice Theme Modified by the RavenNuke™ Team ::

:: W3C CSS Compliance Validation :: W3C HTML 4.01 Transitional Compliance Validation ::

zerosum