2012-08-22 106 views
-2

我有三個圖像。php在其他頁面上取值

<a href="a.php" class="btn"><img src="http://localhost/aaa/wp-content/themes/aaa/img/bouquet/1.png"><span class="bqy_no">1</span></a> 
<a href="a.php" class="btn"><img src="http://localhost/aaa/wp-content/themes/aaa/img/bouquet/2.png"><span class="bqy_no">2</span></a> 
<a class="show_img3 btn" href="a.php"><img src="http://localhost/aaa/wp-content/themes/aaa/img/bouquet/2.png"><span class="bqy_no">BRAUCHE MEHR</span></a><div class="hide_img3"><a href=#>2</a><a href="#">3</a>` 

我想是在1日的點擊,我應該被重定向到一個頁面a.php只會如果點擊thrugh 1,即獲得價值,然後在a.php只會我應該得到1,如果點擊throught 2,我應該得到2 a.php只會

+2

http://whathaveyoutried.com - 顯示我們的東西你已經嘗試過,並且遇到問題。 – fdomig

+0

我看到很多這樣的評論;通常情況下,人們不知道從哪裏開始,所以他們首先要問(所以他們什麼都沒有嘗試)。我沒有看到任何問題。不過,如果他們首先做了一些Google搜索,那將是一件好事。 – user1477388

回答

3

添加ID作爲URL查詢,你將能夠獲得他們的淨頁面上$_GET['id']

<a href="a.php?id=1" class="btn"><img src="http://localhost/aaa/wp-content/themes/aaa/img/bouquet/1.png"><span class="bqy_no">1</span></a> 
<a href="a.php?id=2" class="btn"><img src="http://localhost/aaa/wp content/themes/aaa/img/bouquet/2.png"><span class="bqy_no">2</span></a> 
<a class="show_img3 btn" href="a.php?id=3"><img src="http://localhost/aaa/wp-content/themes/aaa/img/bouquet/2.png"><span class="bqy_no">BRAUCHE MEHR</span></a><div class="hide_img3"><a href=#>2</a><a href="#">3</a> 
3

你應該在你的鏈接中使用$ _GET變量,像這樣:

<a href="a.php?value=1" class="btn"><img src="http://localhost/aaa/wp-content/themes/aaa/img/bouquet/1.png"><span class="bqy_no">1</span></a> 
<a href="a.php?value=2" class="btn"><img src="http://localhost/aaa/wp-content/themes/aaa/img/bouquet/1.png"><span class="bqy_no">1</span></a> 

然後,你的a.php只會頁面上,你可以得到的價值,像這樣:

<?php 

echo $_GET['value']; 

?> 

注:強烈建議不要使用$ _GET沒有固定的數據。請閱讀PHP輸入安全性。 ???

1

添加值= 1,值= 2,值= 3到每一個環節,然後在a.php只會,使用此:

<?php 

echo $_GET['value']; 
// 1, 2 or 3 depending on the image clicked 
?> 
相關問題