Page 1 of 1

Website Multi logo help

Posted: Wed Sep 22, 2010 5:14 pm
by Kintama
hi i was wonder is there a way to get multi logos on a webpage that change each time you refresh or go on a new page ?

Re: Website Multi logo help

Posted: Wed Sep 22, 2010 5:51 pm
by hallsofvallhalla
put your logo code in PHP using echo, and make the name of the logo a variable, then randomize the name

example

Code: Select all

$randomlogo = rand(1,3);
if ($randomlogo == 1)
{
$logoname = "superlogo";
}
if ($randomlogo == 2)
{
$logoname = "goofylogo";
}
if ($randomlogo == 3)
{
$logoname = "basiclogo";
}
echo "<img = " . $logoname . ".png>";

Re: Website Multi logo help

Posted: Wed Sep 22, 2010 7:37 pm
by Loopy
Another way is to rename all your logos with a number (e.g. 1.jpg, 2.jpg, 3.jpg), and then just echo out the random number:

Code: Select all

<?php
$image=(rand(0,5)+1);
echo "<img src=\"/path/to/logos/" . $image . ".jpg\""; ?>
With random logos, you might only have a few... but a if you wanted to incorporate just a random image (perhaps a subset of a picture gallery, or perhaps you display random ads on your website). A good way to expand upon the above without the need to edit the code every time a new image comes along is to rename the images to the numbering system (as above), upload them all to the same directory, read the contents of the directory into an array, count the element in the array, and then display the whatever image randomly. That way, you don't have to edit the code each time a new image comes along, you just upload the image to the directory, and the code automatically picks between all of them, whether you have 3 images, or 300.

Re: Website Multi logo help

Posted: Wed Sep 22, 2010 7:54 pm
by Kintama

Code: Select all

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en-GB" lang="en-GB">
<head>
<title>ºDBº Clan MW2</title>
<link rel="stylesheet" type="text/css" media="all" href="style.css" />
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<script type="text/javascript" src="js/jquery.js"></script>
<script type="text/javascript" src="js/lib.js"></script>
</head>
<body>

  <div id="header_img">

   
    </div>
  </div>
  <div id="top_bar">
 <div id="wrapper">

 
    
     
    <ul id="header_bar_right">
      <li>home</li>
      <li><a href="members.html">Members</a></li>
      <li><a href="#">Forums</a></li>
      <li><a href="#">Apply</a></li>
	  <li><a href="#">Chat</a></li>
	  <li><a href="#">Squads</a></li>
    </ul>
  </div>
    </ul>
  </div>
  <div id="left_col">
    <div class="left_header">Latest News</div>
    <div class="left_wrap">
      <ul>
        <li>
          <div class="float_left"><b>----------------------</b></div>
          <div class="float_right">----</div>
        </li>
        <li>
          <div class="float_left"><b>----------------------</b></div>
          <div class="float_right">----</div>
        </li>
        <li>
          <div class="float_left"><b>----------------------</b></div>
          <div class="float_right">----</div>
        </li>
        <li>
          <div class="float_left"><b>----------------------</b></div>
          <div class="float_right">----</div>
        </li>
        <li>
          <div class="float_left"><b>----------------------</b></div>
          <div class="float_right">----</div>
        </li>
      </ul>
    </div>
    <div class="left_header">Current Members</div>
    <div class="members_wrap">
      <div class="members_bar1">
        <div class="members_class"><img src="images/presticon.jpg" alt=""/> ---</div>
        <div class="members_class2"><img src="images/presticon.jpg" alt=""/> ---</div>
      </div>
      <div class="members_bar2">
        <div class="members_class"><img src="images/presticon.jpg" alt=""/> ---</div>
        <div class="members_class2"><img src="images/presticon.jpg" alt=""/> ---</div>
      </div>
      <div class="members_bar1">
        <div class="members_class"><img src="images/presticon.jpg" alt=""/> ---</div>
        <div class="members_class2"><img src="images/presticon.jpg" alt=""/> ---</div>
      </div>
      <div class="members_bar2">
        <div class="members_class"><img src="images/presticon.jpg" alt=""/> ---</div>
        <div class="members_class2"><img src="images/presticon.jpg" alt=""/> ---</div>
      </div>
      <div class="members_bar1">
        <div class="members_class"><img src="images/presticon.jpg" alt=""/> ---</div>
        <div class="members_class2"><img src="images/presticon.jpg" alt=""/> ---</div>
      </div>
    </div>
    <div class="left_header">Servers</div>
    <div class="left_wrap">
      <ul>
        <li>
          <div class="float_left"><b>-----</b></div>
          <div class="float_right">---</div>
        </li>
        <li>
          <div class="float_left"><b>-----</b></div>
          <div class="float_right">---</div>
        </li>
        <li>
          <div class="float_left"><b>-----</b></div>
          <div class="float_right">---</div>
        </li>
        <li>
          <div class="float_left"><b>-----</b></div>
          <div class="float_right">---</div>
        </li>
        <li>
          <div class="float_left"><b>-----</b></div>
          <div class="float_right">---</div>
        </li>
        <li>
          <div class="float_left"><b>-----</b></div>
          <div class="float_right">---</div>
        </li>
      </ul>
    </div>
    <div class="left_header">Useful Links</div>
    <ul id="links_list">
      <li><a href="http://www.codforums.com">CoDForums<br/>
        <span>http://www.codforums.com</span></a></li>
      <li class="links2"><a href="http://www.callofduty.com">Call of Duty HQ<br/>
        <span>http://www.callofduty.com</span></a></li>
      <li><a href="http://www.twitter.com/CoDForums">Twitter<br/>
        <span>http://www.twitter.com/CoDForums</span></a></li>
      <li class="links2"><a href="http://www.infinityward.com">Infinity Ward<br/>
        <span>http://www.infinityward.com</span></a></li>
      <li><a href="http://www.youtube.com/codforumsyt">Youtube<br/>
        <span>http://www.youtube.com/codforumsyt</span></a></li>
    </ul>
  </div>
  <div id="right_col">
    <div class="post_wrapper"> <img src="images/post_a.jpg" alt="" />
      <p>Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry's standard dummy text ever since the 1500s, when an unknown printer took a galley of type and scrambled it to make a type specimen book. It has survived not only five centuries, but also the leap into electronic typesetting, remaining essentially unchanged. It was popularised in the 1960s with the release of Letraset sheets containing Lorem Ipsum passages, and more recently with desktop publishing software like Aldus PageMaker including versions of Lorem Ipsum.</p>
      <p>It is a long established fact that a reader will be distracted by the readable content of a page when looking at its layout. The point of using Lorem Ipsum is that it has a more-or-less normal distribution of letters, as opposed to using 'Content here, content here', making it look like readable English. Many desktop publishing packages and web page editors now use Lorem Ipsum as their default model text, and a search for 'lorem ipsum' will uncover many web sites still in their infancy. Various versions have evolved over the years, sometimes by accident, sometimes on purpose (injected humour and the like).</p>
    </div>
    <div class="post_wrapper"> <img src="images/post_b.jpg" alt="" />
      <p>Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry's standard dummy text ever since the 1500s, when an unknown printer took a galley of type and scrambled it to make a type specimen book. It has survived not only five centuries, but also the leap into electronic typesetting, remaining essentially unchanged. It was popularised in the 1960s with the release of Letraset sheets containing Lorem Ipsum passages, and more recently with desktop publishing software like Aldus PageMaker including versions of Lorem Ipsum.</p>
    </div>
    <div id="sub_news">
      <div class="sub_title"><span>First MW2 ClanMatch Results</span>
        <div class="divider4"></div>
        <span class="span_right">20/11/2009</span><a href="javascript:;"><img src="images/expand.gif" alt="1" /></a></div>
      <div class="post_wrapper" style="display:none;" id="1"> <img src="images/post_a.jpg" alt="" />
        <p>Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry's standard dummy text ever since the 1500s, when an unknown printer took a galley of type and scrambled it to make a type specimen book. It has survived not only five centuries, but also the leap into electronic typesetting, remaining essentially unchanged. It was popularised in the 1960s with the release of Letraset sheets containing Lorem Ipsum passages, and more recently with desktop publishing software like Aldus PageMaker including versions of Lorem Ipsum.</p>
      </div>
      <div class="sub_title"><span>MW2 is here! Initial thoughts</span>
        <div class="divider4"></div>
        <span class="span_right">16/11/2009</span><a href="javascript:;"><img src="images/expand.gif" alt="2" /></a></div>
      <div class="post_wrapper"  style="display:none;" id="2">
        <p>Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry's standard dummy text ever since the 1500s, when an unknown printer took a galley of type and scrambled it to make a type specimen book. It has survived not only five centuries, but also the leap into electronic typesetting, remaining essentially unchanged. It was popularised in the 1960s with the release of Letraset sheets containing Lorem Ipsum passages, and more recently with desktop publishing software like Aldus PageMaker including versions of Lorem Ipsum.</p>
      </div>
    </div>
  </div>
  <div id="footer">
    <div id="footer_left"> Copyright © <b>ºDBº MW2 Clan</b> 2010.<br/>

</div>
</body>
</html>
were would yu put put it on this cde

Re: Website Multi logo help

Posted: Wed Sep 22, 2010 9:13 pm
by Loopy
Ideally you'd make a function out of it.. but if you just want a quick and dirty insert, you'd do something like this:

Code: Select all

  <div id="header_img">
<?php
$image=(rand(0,5)+1);
echo "<img src=\"/path/to/logos/" . $image . ".jpg\""; ?>
</div>
There are a couple of things you need to change though.. the "5" in the "rand" function you need to change to the number of logos you have. So if you have 7 logos you want to rotate between, you'd change that line to:

Code: Select all

$image=(rand(0,7)+1);
Hall's method works the same way. Make sure you save your file as a .php file, and have php running on your server.

The other thing you need to change is the "/path/to/logos/" by inserting the actual path to the directory that the images are stored in. So from your home directory, maybe you've saved your logos in a path something like this graphics/page_elements/logos/

So you'd change that line to:

Code: Select all

echo "<img src=\"graphics/page_elements/logos/" . $image . ".jpg\""; ?>
Remember using my method you must also rename the images to a number (i.e. 1.jpg, 2.jpg).

Re: Website Multi logo help

Posted: Wed Sep 22, 2010 9:19 pm
by Kintama
thanks for the reply ill test it out ater this match on halo reach so i hope it works ^^

Re: Website Multi logo help

Posted: Wed Sep 22, 2010 10:03 pm
by Kintama
thanks Loopy it work like a charm and thanks halls

Re: Website Multi logo help

Posted: Fri Sep 24, 2010 1:34 pm
by Chris
A better way would be to make an array with a list of image urls:

Code: Select all

$logos = array( 'logo1.jpg',
                'logo2.jpg',
                'logo3.jpg' );
 
Then use rand() to make a random number between 0 and the amount of values in the array-1.

Code: Select all

echo "<img src=\"" . $logos[ rand( 0, (count($logos)-1) ) ] . "\" alt=\"\" />";
 

Re: Website Multi logo help

Posted: Tue Oct 05, 2010 1:44 am
by ZeroComp
Just a question what would you do to stop it from picking the same logo twice?

Re: Website Multi logo help

Posted: Tue Oct 05, 2010 9:23 am
by Chris
A session.