<?php
$url = 'http://'.$_SERVER['HTTP_HOST'].$_SERVER['REQUEST_URI'];

// Strip the query string from URL
list($url,) = explode('?', $url);

// Remove 'sort' from querystring if exist
if (isset($_GET['baseC']))
    unset($_GET['baseC']);

// Rebuild query string, append with '&'
$url .= '?'. http_build_query($_GET).(count($_GET) ? '&' : '');

if (filter_var($url, FILTER_VALIDATE_URL))
{ ?>         
    
<div class="btn-group">
  <a class="btn dropdown-toggle" data-toggle="dropdown" href="#">
    Currency
    <span class="caret"></span>
  </a>
  <ul class="dropdown-menu">         
      
<?php while ($currencyData = mysqli_fetch_array($currency_code)) { 
	$cucode = $currencyData['code'];
?>    
    <li><a href="<?php echo $url; ?>baseC=<?php echo $cucode; ?>"><?php echo $cucode; ?></a></li>

<?php } ?>
      
  </ul>
</div>
    
<?php } ?>