Jump to content

$_GET


Deivas

Recommended Posts

Could you explain you problem a little more? What are you trying to do?

there's $_GET[] to get a variable from the url

and there's $_POST[] to get something from a form the page before

 

I have a lot of links in my website, and on most of them I need to do this (this might be wrong) :

if($_GET['type'] != null){
                                                if($_GET['order'] == null){
                                            $nav .= " <a href=\"$self?page=$page&&type=$type\">$page</a> ";
                                                }
                                                if($_GET['order'] != null){
                                            $nav .= " <a href=\"$self?page=$page&&type=$type&&order=$order\">$page</a> ";
                                                }
                                            }
                                            if($_GET['type'] == null){
                                            $nav .= " <a href=\"$self?page=$page\">$page</a> ";
                                            }

and etc ,

I am asking if it is possible to do it faster?

Link to comment
https://forums.phpfreaks.com/topic/195127-_get/#findComment-1025654
Share on other sites

Build you're url as you check to see if the $_GET['type'] and $_GET['order'] exists. Eg:

 

$url = "<a href=\"$self?page=$page";

if(isset($_GET['type']) && !empty($_GET['type']))
    $url .= "&type=$type";

if(isset($_GET['order']) && !empty($_GET['order']))
    $url .= "&order=$order";

$url .= "\">$page</a>";

echo $url;

 

Link to comment
https://forums.phpfreaks.com/topic/195127-_get/#findComment-1025726
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.