Jump to content

Random image by click


Freq245

Recommended Posts

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

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

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.