0

www.mysite.com/?q=portraits#

I want a span within my menu to display the current section (ie. portraits)

I'm sure this is simple. Your help is much appreciated!

rootsup
  • 315
  • 2
  • 17

2 Answers2

0

it's been a long time since i've used php, but the the variable you are referring to is what's known as a query string parameter, which is passed as a $_GET array in php. you can access the specific variable by using a string indexer of the array. in your markup:

<span><?php echo $_GET["q"]; ?></span>
WickyNilliams
  • 5,218
  • 2
  • 31
  • 43
0

You'll probably have to use javascript, if you're not working with PHP or something like that.

How to extract the get-query with javascript is explained here: How can I get query string values in JavaScript?

Then you can fork the result and add/remove content to/from the element you want to manipulate.

Community
  • 1
  • 1
Quasdunk
  • 14,944
  • 3
  • 36
  • 45
  • Quasdunk... I'm not sure exactly how to implement the code since there is a find function included in that script (i'm not fluent in scripting at all :( ) the index is a php file so i could use the get function... but all the subsequent pages are html – rootsup Aug 03 '11 at 20:51
  • @rootsup Are they really HTML or are the extensions just rewritten (e.g. by the .htaccess)? Are they called directly or are they just being included? If they're just part of a template, you can use PHP in them. Otherwise it might be wiser and much easier renaming them to .php. – Quasdunk Aug 03 '11 at 20:58
  • alright, I think I might use the code specified by nicksta and just rename everything to .php! Thanks for your time – rootsup Aug 03 '11 at 21:11
  • @rootsup Yep, that should be the best solution. There won't be any disadvantages, you can run regular html and js code in there, the only difference is, that you can also use PHP additionally. – Quasdunk Aug 03 '11 at 21:14
  • You could probably answer > http://stackoverflow.com/questions/6934021/html-php-question-get-command for me real quickly? It's my last question as my site is really simple – rootsup Aug 03 '11 at 22:23