我有以下的HTML/PHP代碼:遞增計數器當單擊PHP
<img id="imageViewer"src="someData" height="" width="" alt=""></img>
<?php
//a counter so we know what image to return
$counter =0;
print("<a href='#'>Click me</a>");
$imageArray = array(0 => "image link", 1 => "image link", 2=>"image link", 3=>"image link");
if ($counter<= count($imageArray))
{
$pathToImage = imageArray[$counter];
}
else
{
$counter =0;
$pathToImage = imageArray[$counter];
}
//code to replace old image with new image
?>
如何增加$counter
鏈接被點擊的時候,然後改變圖像展現新形象基於從數組中選擇什麼?
我該如何使用Javascript來做到這一點? – zpesk 2010-11-09 22:34:32
@zPesk你會發送一個ajax請求到一個PHP腳本,它增加了存儲在數據庫中的計數器。 – JAL 2010-11-09 23:24:53