Freq245 Posted April 20, 2006 Share Posted April 20, 2006 I'm using this php code at the moment, but it doesn't work for me, though, at an other server it does.[code]$bilder=array("...","...");mt_srand ((double)microtime()*1000000);$zahl = mt_rand(0,(count($bilder) - 1));echo ("<a href=\"http://www...".$bilder[$zahl]."\"></a>");[/code]I've a table and would like to display an image in it, which changes if one clicks at it.Thank you. Link to comment https://forums.phpfreaks.com/topic/7950-random-image-by-click/ Share on other sites More sharing options...
kenrbnsn Posted April 20, 2006 Share Posted April 20, 2006 Look at the function [a href=\"http://www.php.net/array_rand\" target=\"_blank\"]array_rand()[/a][code]<?php$bilder=array("...","...");$rand_key = array_rand($bilder);echo '<a href="http://www...' . $bilder[$rand_key] . '"></a>';?>[/code]Ken Link to comment https://forums.phpfreaks.com/topic/7950-random-image-by-click/#findComment-28980 Share on other sites More sharing options...
Freq245 Posted April 20, 2006 Author Share Posted April 20, 2006 Your code doesn't work for me, too. :( Link to comment https://forums.phpfreaks.com/topic/7950-random-image-by-click/#findComment-28988 Share on other sites More sharing options...
kenrbnsn Posted April 20, 2006 Share Posted April 20, 2006 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 Link to comment https://forums.phpfreaks.com/topic/7950-random-image-by-click/#findComment-29028 Share on other sites More sharing options...
Freq245 Posted April 21, 2006 Author Share Posted April 21, 2006 It's working now. There was a bug in the server, so I wasn't able to use php. Link to comment https://forums.phpfreaks.com/topic/7950-random-image-by-click/#findComment-29305 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.