2012-08-22 32 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 
?>