Jump to content

Archived

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

Freq245

Random image by click

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.

Share this post


Link to post
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

Share this post


Link to post
Share on other sites
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

Share this post


Link to post
Share on other sites
It's working now. There was a bug in the server, so I wasn't able to use php.

Share this post


Link to post
Share on other sites

×

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.