Jump to content

how to make every other click on a link display a different link ?


jjk2

Recommended Posts

<?php
session_start();

print_r($_SESSION);

if($_SESSION['clicks'] >= 0){
$_SESSION['clicks'] += 1;
}else {
$_SESSION['clicks'] = 0;
}

$urls = array(0 => 'http://google.com', 1 => 'http://yahoo.com', 2 => 'http://msn.com', 3 => 'http://omgpie.com');

echo "<a href=\"".$urls[$_SESSION['clicks']]."\">".$urls[$_SESSION['clicks']]."</a>\n";
?>

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.