Page 1 of 1

url variable link

Posted: Mon May 11, 2009 9:22 am
by berniez
Hi I have a page1 with a variable link page2.php?cat=Accomodation&list=Backpackers Hostel then on page2.php I have

Code: Select all

<?php 
$cat = $_GET['cat']; 
$list = $_GET['list'];
echo ("{$cat} : {$list}");?>
which works perfectly and displays Accomodation : Backpackers Hostel
How do I get the echo part to turn into links. I need on page2 the 'Accomodation : Backpackers Hostel' to be made into links that I can click on them. 2 separate links, 1 for Accomodation and the 2nd one for Backpackers Hostel.
Could someone please help I am at a total loss as to convert them to links.
Thanks for your help

Re: url variable link

Posted: Mon May 11, 2009 10:41 am
by Yossarian

Code: Select all

<?php
 
if( isset( $_GET['cat'] ) ){
 
// make it safe to display on a html page, escape it
  $cat_output = htmlentities( $_GET['cat'] ) ;
  echo '<a href="anotherpage.php?cat=' . $cat_output  . '">' . $cat_output .  '</a> ' ;
}else{
// category not set
 
}
 
?>
Look carefully at the html source code of the page to make sure that the use of quotes does not get mixed up, there are lots of ways of using quotes.