[PHP] Re: Please Help - getting a hightlight depending on selected page

2001-08-24 Thread Martin Hughes

Sorry Hugh - didn't mean to send it just to you!!

Hi!

Thanks for the help!

It works great, but I've now made the array 2 dimensional:

?php
$index = array (
The Music Behindbr /Les Miseacute;rables = array (About Les
Miseacute;rables),
Introduction = array (About Les Miseacute;rables),
Changes amp; Cuts = array (About Les Miseacute;rables),
Scores = array (About Les Miseacute;rables),
Orchestra = array (About Les Miseacute;rables),
Synthesizers = array (About Les Miseacute;rables),
Sound System = array (About Les Miseacute;rables),
Articles = array (About Les Miseacute;rables),
21st Centurybr /Les Miseacute;rables = array (About Les
Miseacute;rables),
Information = array (About Les Miseacute;rables),
Discussion Forums = array (About Les Miseacute;rables)
);
?

(they're not all the same - it's just for quick tesing purposes!)

Now in the nav menu I get:

Warning: Undefined offset: 0 in E:\inetpub\wwwroot\index.php on line 103

Warning: Undefined offset: 1 in E:\inetpub\wwwroot\index.php on line 103

Warning: Undefined offset: 2 in E:\inetpub\wwwroot\index.php on line 103

Warning: Undefined offset: 3 in E:\inetpub\wwwroot\index.php on line 103

etc... down to 10




the rest of the script is:

?php
$items = count($index);
for($i = 0; $i  $items; $i++) {
echo \ntrtd class='navtext';

if ($sect == $i)
echo  id='sel';

echo a href='index.php?sect=$iid=0'.$index[$i]./a;
 LINE 103

echo /td/tr;
}
?


is it something to do with the count($index)?

Thanks for all the help!

Martin-)



-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]




[PHP] Re: Please Help - getting a hightlight depending on selected page

2001-08-23 Thread Martin Hughes

Thanks everyone for the help!!!

Martin



-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]




[PHP] Re: Please Help - getting a hightlight depending on selected page

2001-08-22 Thread Gabe da Silveira

Is the menu part of each page?  Or is it a separate file/script that 
gets included in each page? Or is the navigation in a separate frame?

If the menu is hard-coded into each page, then there's no reason to use 
PHP, because you have to modify each page ANYWAY, so you might as well 
just set each page to what it needs to be.

The only way you are going to be able to accomplish this with 
significantly less work than that is if you store your image URLs and 
menu links in a database.  In that case as you printed out the links, 
you would check each one to see if $PHP_SELF was equal to the link.

Ultimately there are so many ways that you could be doing this that 
there is no simple answer.  Post your menu code, and tell us how it gets 
included in your page and then we can help... 

In article [EMAIL PROTECTED],
 [EMAIL PROTECTED] (Martin Hughes) wrote:

 Hi can anyone help me please!?
 
 I have a page that has a navigation table on the left with various links:
 
 Information
 Software
 Cars
 Dishwashers
 Paper
 Contact
 etc...
 
 (not the real links ;))
 
 and I want the cell of the section I am in to be highlighted (ie if I am in
 Cars I want the Cars link to have a red background). I have set it up so
 that in CSS the id sel is a red b/g.
 
 How do I set the id of a certain cell to sel taking it from the url
 (index.php?menu=cars as a very bad example of php coding :)).
 
 Cheers
 
 Martin
 


-- 
__
Gabe da Silveira, Web Designer
Twin Cities Student Unions
University of Minnesota
http://www.coffman.umn.edu

wFone: (612)624-7270
eMail: [EMAIL PROTECTED]
hPage: http://www.visi.com/~jiblet

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]




[PHP] Re: Please Help - getting a hightlight depending on selected page

2001-08-22 Thread Martin Hughes

OK here's the code in the page:

!-- Start Navigation --
div id=navbar
table class=navtable width=160 cellpadding=4
!-- Navigation Bar Heading --
tr
 td class=navheadWelcome/td
/tr
trtd class=navtext id=sela href=Home/a/td/tr
trtd class=navtexta href=Introduction/a/td/tr
trtd class=navtexta href=Changes amp; Cuts/a/td/tr
trtd class=navtexta href=Scores/a/td/tr
trtd class=navtexta href=Orchestra/a/td/tr
trtd class=navtexta href=Synthesizers/a/td/tr
trtd class=navtexta href=Sound System/a/td/tr
trtd class=navtexta href=Articles/a/td/tr
trtd class=navtexta href=21st Century Les
Miseacute;rables/a/td/tr
trtd class=navtexta href=Information/a/td/tr
trtd class=navtexta href=Discussion Forums/a/td/tr

/table
/div
!-- End Navigation --


I am using this 1 page as the php 'template' with content added depending on
the url. For example, to go to the synthesizers page the url is:
index.php?sect=5id=0page=31

where sect=5 is the part that sets the menu highlight (the menu is alway the
same, hard-coded into the page - all I want to do is change the css id=sel
from Home to Synthesizers.

Cheers

Martin



-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]




[PHP] Re: Please Help - getting a hightlight depending on selected page

2001-08-22 Thread Gabe da Silveira

Okay, well you could either put code like this into each td cell like 
this:

td class=navtext ?php if (sect == 5) print id=\sel\; ?

That is kind of ugly, however.  A more elegant solution would be to make 
an array containing the links then do a loop kind of like this (I'm just 
typing the code off the top of my head, so there is likely to be some 
errors):

$menuItems = array('Home', 'Introduction', 'Changes amp; Cuts', 
'Scores', 'Orchestra', 'Synthesizers', 'Sound System', 'Articles');
$i = 0;
foreach ($menuItems as $item) {
   if($sect == $i) {
  print trtd class=\navtext\ id=\sel\a 
href=\\$item/a/td/tr\n;
   } else {
  print trtd class=\navtext\a 
href=\\$item/a/td/tr\n;
   }
   $i++;
}

The obvious problem with my solution is the links will also presumably 
have to be entered into an array, and I don't think the foreach 
construct can work on two arrays simultaneously, but you can use the $i 
variable as the index to your second array.

In article [EMAIL PROTECTED],
 [EMAIL PROTECTED] (Martin Hughes) wrote:

 OK here's the code in the page:
 
 !-- Start Navigation --
 div id=navbar
 table class=navtable width=160 cellpadding=4
 !-- Navigation Bar Heading --
 tr
  td class=navheadWelcome/td
 /tr
 trtd class=navtext id=sela href=Home/a/td/tr
 trtd class=navtexta href=Introduction/a/td/tr
 trtd class=navtexta href=Changes amp; Cuts/a/td/tr
 trtd class=navtexta href=Scores/a/td/tr
 trtd class=navtexta href=Orchestra/a/td/tr
 trtd class=navtexta href=Synthesizers/a/td/tr
 trtd class=navtexta href=Sound System/a/td/tr
 trtd class=navtexta href=Articles/a/td/tr
 trtd class=navtexta href=21st Century Les
 Miseacute;rables/a/td/tr
 trtd class=navtexta href=Information/a/td/tr
 trtd class=navtexta href=Discussion Forums/a/td/tr
 
 /table
 /div
 !-- End Navigation --
 
 
 I am using this 1 page as the php 'template' with content added depending on
 the url. For example, to go to the synthesizers page the url is:
 index.php?sect=5id=0page=31
 
 where sect=5 is the part that sets the menu highlight (the menu is alway the
 same, hard-coded into the page - all I want to do is change the css id=sel
 from Home to Synthesizers.
 
 Cheers
 
 Martin
 


-- 
__
Gabe da Silveira, Web Designer
Twin Cities Student Unions
University of Minnesota
http://www.coffman.umn.edu

wFone: (612)624-7270
eMail: [EMAIL PROTECTED]
hPage: http://www.visi.com/~jiblet

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]




[PHP] Re: Please Help - getting a hightlight depending on selected page

2001-08-22 Thread Hugh Bothwell


Martin Hughes [EMAIL PROTECTED] wrote in message
[EMAIL PROTECTED]">news:[EMAIL PROTECTED]...
 OK here's the code in the page:

 !-- Start Navigation --
 div id=navbar
 table class=navtable width=160 cellpadding=4
 !-- Navigation Bar Heading --
 tr
  td class=navheadWelcome/td
 /tr
 trtd class=navtext id=sela href=Home/a/td/tr
 trtd class=navtexta href=Introduction/a/td/tr
 trtd class=navtexta href=Changes amp; Cuts/a/td/tr
 trtd class=navtexta href=Scores/a/td/tr
 trtd class=navtexta href=Orchestra/a/td/tr
 trtd class=navtexta href=Synthesizers/a/td/tr
 trtd class=navtexta href=Sound System/a/td/tr
 trtd class=navtexta href=Articles/a/td/tr
 trtd class=navtexta href=21st Century Les
 Miseacute;rables/a/td/tr
 trtd class=navtexta href=Information/a/td/tr
 trtd class=navtexta href=Discussion Forums/a/td/tr

 /table
 /div
 !-- End Navigation --


 I am using this 1 page as the php 'template' with content added depending
on
 the url. For example, to go to the synthesizers page the url is:
 index.php?sect=5id=0page=31

 where sect=5 is the part that sets the menu highlight (the menu is alway
the
 same, hard-coded into the page - all I want to do is change the css
id=sel
 from Home to Synthesizers.

div id=navbar
table class=navtable width=160 cellpadding=4
trtd class=navheadWelcome/td/tr

?php

$index = array(
Home,
Introduction,
Changes amp; Cuts,
Scores,
Orchestra,
Synthesizers,
Sound System,
Articles,
21st Century Les Miseacute;rables,
Information,
Discussion Forums
);

$items = count($index);
for($i = 0; $i  $items; $i++) {
echo \ntrtd class='navtext';

if ($sect == $i)
echo  id='sel';

echo a href='index.php?sect=$i'.$index[$i]./a;

echo /td/tr;
}
?

/table
/div




-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]