Jump to content

Recommended Posts

echo '<a href="?';
if ($_GET['sort']) echo 'sort='.$sort.'&';
if ($_GET['flow']) echo 'flow='.$flow.'&';
if ($_GET['game_id']) echo 'game_id='.$_GET['game_id'].'&';
if ($_GET['server_id']) echo 'server_id='.$_GET['server_id'].'&';
echo 'page='.$pagenext.'">NEXT»</a>';

 

Is there an easier way to construct a link while keeping all the set $_GET values?

Link to comment
https://forums.phpfreaks.com/topic/55976-rollover-_gets-easier-way-to-do-it/
Share on other sites

Maybe store the URL in a variable?

 

<?php

$link = "";

if ($_GET['sort']) $link .= 'sort='.$sort.'&';
if ($_GET['flow']) $link .= 'flow='.$flow.'&';
if ($_GET['game_id']) $link .= 'game_id='.$_GET['game_id'].'&';
if ($_GET['server_id']) $link .= 'server_id='.$_GET['server_id'].'&';

echo '<a href="?'.$link.'?page='.$pagenext.'">NEXT»</a>';

?>

 

Other than that...it looks like a pretty solid method for putting together the link.

 

Here is a different approach at it....

 

<?php

$link = "";

foreach ($_GET as $key => $val){
   $link .= '&'.$key.'='.$val;
}

$link .= '&page='.$pagenext;

echo '<a href="'.$link.'">Test</a>';

?>

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.