geenee Posted August 2, 2008 Share Posted August 2, 2008 Ok, there may well be a very simple solution to this problem but I can't think of it so here it is.. I've got several pages on a web site, the first is the index.php the others are index.php?type=1, index.php?type=2 etc... each page lists items and when you click on an item it displays the item's info, the link(s) to display the item's info should be: <a href='{$PHP_SELF}&pid={$row[pid]}'>Item Link</a> this works fine on all the pages apart from index.php, as the link comes out as: index.php&pid=1 whereas it should be index.php?pid=1 What is the simplist way for the script to use ? instead of & if there is no variable already being send through the URL?? Thanks Quote Link to comment https://forums.phpfreaks.com/topic/117820-adding-variables-to-url/ Share on other sites More sharing options...
wildteen88 Posted August 2, 2008 Share Posted August 2, 2008 Do: $sep = ( isset($_GET) && (count($_GET) > 1) ) ? '&' : '?'; echo '<a href="' . $_SERVER['PHP_SELF'] . $sep . 'pid=' . $row['pid'] . '">Item Link</a>'; Quote Link to comment https://forums.phpfreaks.com/topic/117820-adding-variables-to-url/#findComment-606093 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.