我有三张照片。
<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>`
我希望点击第一个,我应该被重定向到一个页面a.php并获得值,即如果点击thrugh 1,然后在a.php我应该得到1,如果点击通过2,我应该得到2在a.php上
答案 0 :(得分:3)
将ID
添加为网址查询,您就可以使用$_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>
答案 1 :(得分: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输入安全性。
答案 2 :(得分:1)
为每个链接添加?value = 1,?value = 2,?value = 3,然后在a.php上,使用:
<?php
echo $_GET['value'];
// 1, 2 or 3 depending on the image clicked
?>