作者 主題: 一個圖片按鈕有兩個連結去輪替要怎麼寫呢?  (閱讀 4033 次)

0 會員 與 1 訪客 正在閱讀本文。

dodogogox

  • 可愛的小學生
  • *
  • 文章數: 1
    • 檢視個人資料
公司網站左上角的"新業務專區"按鈕想要做兩個連結輪替
www.tabc.com.tw
以下是我寫的,我是PHP新手...不知道是哪裡出問題...

<?PHP
 $arr = array("http://tw.yahoo.com/", "http://google.com/");
?>
                  
<td bgcolor="#000000">
<img src="../../images/index/index_login0102.jpg" alt="" onclick="window.open('<?=array_rand($arr, 1)?>', 'mywindow')"  " style="cursor:pointer" />


當我在網頁上次測試後她顯示卻是輪替www.tabc.com.tw/0
                                                   www.tabc.com.tw/1

是我少了少麼嗎...~_~"

湯姆貓

  • 活潑的大學生
  • ***
  • 文章數: 475
    • 檢視個人資料
好像少了echo吧!!

Yamaka

  • 俺是博士!
  • *****
  • 文章數: 4913
    • 檢視個人資料
    • http://www.ecmagic.com
公司網站左上角的"新業務專區"按鈕想要做兩個連結輪替
www.tabc.com.tw
以下是我寫的,我是PHP新手...不知道是哪裡出問題...

<?PHP
 $arr = array("http://tw.yahoo.com/", "http://google.com/");
?>
                  
<td bgcolor="#000000">
<img src="../../images/index/index_login0102.jpg" alt="" onclick="window.open('<?=array_rand($arr, 1)?>', 'mywindow')"  " style="cursor:pointer" />


當我在網頁上次測試後她顯示卻是輪替www.tabc.com.tw/0
                                                   www.tabc.com.tw/1

是我少了少麼嗎...~_~"

array_rand()傳回的是key...

Description
mixed array_rand ( array $input [, int $num_req = 1 ] )

Picks one or more random entries out of an array, and returns the key (or keys) of the random entries.