Jump to content


Photo

Random image by click


  • Please log in to reply
4 replies to this topic

#1 Freq245

Freq245
  • New Members
  • Pip
  • Newbie
  • 3 posts

Posted 20 April 2006 - 02:09 PM

I'm using this php code at the moment, but it doesn't work for me, though, at an other server it does.

$bilder=array("...","...");
mt_srand ((double)microtime()*1000000);
$zahl = mt_rand(0,(count($bilder) - 1));

echo ("<a href=\"http://www...".$bilder[$zahl]."\"></a>");

I've a table and would like to display an image in it, which changes if one clicks at it.

Thank you.

#2 kenrbnsn

kenrbnsn
  • Staff Alumni
  • Advanced Member
  • 8,235 posts
  • LocationHillsborough, NJ, USA

Posted 20 April 2006 - 02:25 PM

Look at the function [a href=\"http://www.php.net/array_rand\" target=\"_blank\"]array_rand()[/a]

<?php
$bilder=array("...","...");
$rand_key = array_rand($bilder);
echo '<a href="http://www...' . $bilder[$rand_key] . '"></a>';
?>

Ken

#3 Freq245

Freq245
  • New Members
  • Pip
  • Newbie
  • 3 posts

Posted 20 April 2006 - 02:47 PM

Your code doesn't work for me, too. :(

#4 kenrbnsn

kenrbnsn
  • Staff Alumni
  • Advanced Member
  • 8,235 posts
  • LocationHillsborough, NJ, USA

Posted 20 April 2006 - 04:14 PM

What do you me "doesn't work". What is failing? How is it failing? Is there more to your script that you're not posting that could have an impact on this code?

Ken

#5 Freq245

Freq245
  • New Members
  • Pip
  • Newbie
  • 3 posts

Posted 21 April 2006 - 11:42 AM

It's working now. There was a bug in the server, so I wasn't able to use php.




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users