我正在面对有关URL的问题

时间:2016-12-01 15:03:00

标签: php url hyperlink

我必须按此顺序在URL中获得2个参数 http://localhost/StudentGuideBook/AdminPanel/viewInstitute.php?type=Govermnet&Category=University

当我点击这两个值时,我会第一次得到这个,但在此之后我会得到这种类型的链接 http://localhost/StudentGuideBook/AdminPanel/viewInstitute.php?type=Govermnet&Category=University&Category=College&type=Govermnet

我想覆盖该值是链接不能连接这个 anny solutions ???

在代码中我检查了服务器的完整URL $ CompleteLink ='http://'。 $ _SERVER ['HTTP_HOST']。 $ _SERVER [ 'REQUEST_URI'];

<div class="just-padding">
                <div class="list-group list-group-root well">
                    <a href="#" class="list-group-item">Search By Type</a>
                    <div class="list-group">
                       <?php
                        if (strpos($CompleteLink, $mark) !== false){
                            echo "<a href='$CompleteLink&type=Private' class='list-group-item'>Private Institutes</a>";
                            echo "<a href='$CompleteLink&type=Govermnet' class='list-group-item'>Goverment Institutes</a>";
                            echo "<a href='$CompleteLink&type=all' class='list-group-item'>All Institutes</a>";
                        } else {
                            echo "<a href='" . BASE_URL . "AdminPanel/viewInstitute.php?type=Private' class='list-group-item'>Private Institutes</a>";
                            echo "<a href='" . BASE_URL . "AdminPanel/viewInstitute.php?type=Govermnet' class='list-group-item'>Goverment Institutes</a>";
                            echo "<a href='" . BASE_URL . "AdminPanel/viewInstitute.php?type=all' class='list-group-item'>All Institutes</a>";
                        }
                        ?>
                    </div>
                </div>
                <div class="list-group list-group-root well">
                    <a href="#" class="list-group-item">Search By Category</a>
                    <div class="list-group">
                         <?php
                        if (strpos($CompleteLink, $mark) !== false){
                            echo "<a href='$CompleteLink&Category=University' class='list-group-item'>University</a>";
                            echo "<a href='$CompleteLink&Category=College' class='list-group-item'>College</a>";
                            echo "<a href='$CompleteLink&Category=Technical Academy' class='list-group-item'>Technical Academy</a>";
                        } else {
                            echo "<a href='" . BASE_URL . "AdminPanel/viewInstitute.php?Category=University' class='list-group-item'>University</a>";
                            echo "<a href='" . BASE_URL . "AdminPanel/viewInstitute.php?Category=College' class='list-group-item'>College</a>";
                            echo "<a href='" . BASE_URL . "AdminPanel/viewInstitute.php?Category=Technical Academy' class='list-group-item'>Technical Academy</a>";
                        }
                        ?>
                    </div>
                </div>
            </div> 

This is the link i am getting

1 个答案:

答案 0 :(得分:0)

我认为$CompleteLink在回显之前会发生变异。 如果您不想通过代码来查找变异的位置,可以在回复之前尝试$CompleteString = substr($CompleteLink, 0, (strpos($CompleteLink, '?')));