I have a quick question.
Is it possible to do something like this?
The options are generated dynamically based on foreach loop. I want the loop to stop where the $_GET[‘t’] equals the $k and make it selected.
<option value='http://domain.com/<?php print $k; ?>/' <?php if ($k == $_GET['t']) print 'selected'; ?>><?php print $v; ?></option>
Basically is there a way to make the option selected/highlighted based on the provided $_GET[t’] value on the address bar.. I tried it and i get undefined index: t error.
am i missing something?
Thanks a lot.
You get the undefined error because ‘t’ is not in your
$_GETrequest.make sure you are calling the right url (i.e.: example.com/script.php?t=test)
Do make sure you are checking for the value (as others suggested) with
isset($_GET['t'])