如何用&发送参数值GET或POST的字符

时间:2016-12-21 08:05:01

标签: php

有人可以帮我显示数据吗?我的问题是当数据的符号为&来自$_GET以获取href上的数据时,它不会显示。当数据没有&符号时,会显示它。

当标题有&符号时,数据不会显示。

<a href="Reserved.php?Details=<?php echo $Reserve['Title']; ?>"><button name="Details" type="button" value="Details"><i class="fa fa-info-circle"></i> Details</button></a>
<?Php
if(isset($_GET['Details'])){
                $Details = $_REQUEST['Details'];


                    $Reserve_Query = mysql_query("SELECT a.*, b.*, c.*, d.*, e.*, f.* FROM tblReserved a, tblUser b, tblResources c, tblAuthor d, tblCategory e, tblResourcesType f WHERE a.User_ID = b.User_ID AND a.Accession_No = c.Accession_No AND c.Accession_No = d.Accession_No AND c.Category_ID = e.Category_ID AND c.Type_ID = f.Type_ID AND c.Title = '$Details'");
                    $Reserve = mysql_fetch_array($Reserve_Query);
                ?>
                <tr align="center" style="border: 1px solid #115a01;">
                    <td><?php echo $Reserve['Title']; ?></td>
                    <td><?php echo $Reserve['Author']; ?></td>
                    <td><?php echo $Reserve['Category']; ?></td>
                    <td><?php echo $Reserve['Resources_Type']; ?></td>
                </tr>
                <tr><td colspan="4" height="5"></td></tr>
}

1 个答案:

答案 0 :(得分:0)

尝试此功能&#34; urlencode&#34;

//if variable :jeans&shirts   
 echo $variable = urlencode($_GET['variable']);
//out put will be jeans%26shirts

您的代码将

  <a href="Reserved.php?Details=<?php echo urlencode($Reserve['Title']); ?>"><button name="Details" type="button" value="Details"><i class="fa fa-info-circle"></i> Details</button></a>

//您的Reserved.php获取值

 <?php
    if(isset($_GET['Details'])){
                   echo  $Details = urldecode($_REQUEST['Details']);
        }

    ?>