Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/php/261.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Php 如何使用“获取通过id选择的项目”_Php_Get - Fatal编程技术网

Php 如何使用“获取通过id选择的项目”

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">

如何将$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>
如何将$\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";
    }
}
?>