Php 如何使用“获取通过id选择的项目”
如何将$u get方法添加到此代码中,并使其显示为另一页中的苹果Php 如何使用“获取通过id选择的项目”,php,get,Php,Get,如何将$u get方法添加到此代码中,并使其显示为另一页中的苹果 <div class="col-md-3 col-sm-6 post"> <a href="fruit.php?id=1"> <img src="image/apple.jpg"></a> <h4> apple</h4> </div> <div class="col-md-3 col-sm-6 post">
<div class="col-md-3 col-sm-6 post">
<a href="fruit.php?id=1"> <img src="image/apple.jpg"></a> <h4> apple</h4>
</div>
<div class="col-md-3 col-sm-6 post">
<a href="fruit.php?id=2">
<img src="image/orange.jpg"></a>
<h4>orange</h4>
</div>
如何将$\u get方法添加到此代码中,并使其在另一个页面中显示为橙色
<div class="col-md-3 col-sm-6 post">
<a href="fruit.php?id=1"> <img src="image/apple.jpg"></a> <h4> apple</h4>
</div>
<div class="col-md-3 col-sm-6 post">
<a href="fruit.php?id=2">
<img src="image/orange.jpg"></a>
<h4>orange</h4>
</div>
您可以使用查询字符串fruit.php?id=1&fruit\u name=apple或fruit.php?id=1&fruit\u name=orange
尝试:
在fruit.php页面中,您可以执行以下操作:
<?php
if(isset($_GET["id"]))
{
if($_GET["id"]==1)
{
echo "This is an apple in another page";
}
else if($_GET["id"]==2)
{
echo "This is an orange in another page";
}
}
?>
不知道你在问什么。如何在上面的代码中使用$\u,这将帮助我获得我在下一页选择的项目的结果。如果你已经知道id 1是apple,为什么你需要再次发送它?这不是多余的吗?谢谢,你的解释真的很有帮助谢谢,你的解释真的很有帮助如果你觉得这个答案有用,请记为答案。谢谢,你的解释真的很有帮助完美:
<?php
if(isset($_GET["id"]))
{
if($_GET["id"]==1)
{
echo "This is an apple in another page";
}
else if($_GET["id"]==2)
{
echo "This is an orange in another page";
}
}
?>