Cell Colour Change!!!

This is a discussion on Cell Colour Change!!! within the PHP Language forums, part of the PHP Programming Forums category; Hi I am trying to change the colour of a cell depending on what page the user is on.. I ...


Go Back   Usenet Forums > PHP Programming Forums > PHP Language

FAQ Members List Calendar Search Today's Posts Mark Forums Read
  #1 (permalink)  
Old 11-07-2003
Keith Mullin
 
Posts: n/a
Default Cell Colour Change!!!

Hi I am trying to change the colour of a cell depending on what page the
user is on..

I have View.php the is loaded into every page!

This is what I was trying to do but I got no clue how it goes

If page is "home" Then cell colour should be blue
If page is "register" Then cell colour should be Red
If page is "contact us" Then cell colour should be yellow

If some one can help me at least make a basic php structure for this I would
appriciate it!



Reply With Quote
  #2 (permalink)  
Old 11-07-2003
Szar
 
Posts: n/a
Default Re: Cell Colour Change!!!


"Keith Mullin" <keith.mullin@sympatico.ca> wrote in message
news:fNCqb.22446$mB5.1016724@news20.bellglobal.com ...
> Hi I am trying to change the colour of a cell depending on what page the
> user is on..
>
> I have View.php the is loaded into every page!
>
> This is what I was trying to do but I got no clue how it goes
>
> If page is "home" Then cell colour should be blue
> If page is "register" Then cell colour should be Red
> If page is "contact us" Then cell colour should be yellow
>
> If some one can help me at least make a basic php structure for this I

would
> appriciate it!
>



Pass a page var with each link and in the cells:
if($page=="home") {
//make the background this color
} elseif($page=="register") {
//make the background this color
} else {
//and so on
}

Or get a bit fancier and use something like $_SERVER['PHP_SELF']; to see
what page you're on.
Steve.


Reply With Quote
  #3 (permalink)  
Old 11-07-2003
Alvaro G Vicario
 
Posts: n/a
Default Re: Cell Colour Change!!!

*** Keith Mullin wrote/escribió (Thu, 6 Nov 2003 20:45:18 -0800):
> If page is "home" Then cell colour should be blue
> If page is "register" Then cell colour should be Red
> If page is "contact us" Then cell colour should be yellow


Do you mean something like...?

<style>
..blue{
background-color: #89D3F8;
}
..red{
background-color: #FEB7A5;
}
..yellow{
background-color: #FFFFAA;
}
</style>
<?
switch($_SERVER['PHP_SELF']){
case 'home.php':
$style='blue';
break;
case 'register.php':
$style='red';
break;
case 'contact.php':
$style='yellow';
break;
}
?>
<table><tr><td class="<?=$style">.......


--
--
-- Álvaro G. Vicario - Burgos, Spain
--
Reply With Quote
  #4 (permalink)  
Old 11-08-2003
Pedro Graca
 
Posts: n/a
Default Re: Cell Colour Change!!!

Keith Mullin wrote:
> This is what I have but does not work:
>
> <tr <?php if($page!=="home") { print(bgcolor="#006699"); }
> elseif($page!=="compose") { print(bgcolor="#66CC33"); }
> elseif($page!=="registration") {
> print(bgcolor="#FF0000"); }elseif($page!=="contact") {
> print(bgcolor="#FFCC00") else ( print(bgcolor="#006699"); } ?>>


if ($page !== "home") { whatever }

means:

if the contents of the variable named $page are (very) *different* to
"home" then do whatever


I think you want

if ($page === "home") { whatever }

which means: if $page is (very) *equal* to "home" then do whatever



But ... the switch solution provided by another poster is your best bet.

switch ($page) {
case 'home': echo 'bgcolor="#006699"'; break;
case 'compose': echo 'bgcolor="#66CC33"'; break;
// ...
default: echo 'bgcolor="006699"';
}

did you notice the home and default colors are the same?
get the "home" out of the construct to speed up your code a few
milliseconds :)

--
..sig
Reply With Quote
  #5 (permalink)  
Old 11-08-2003
Keith Mullin
 
Posts: n/a
Default Re: Cell Colour Change!!!

This is what I have but does not work:

<tr <?php if($page!=="home") { print(bgcolor="#006699"); }
elseif($page!=="compose") { print(bgcolor="#66CC33"); }
elseif($page!=="registration") {
print(bgcolor="#FF0000"); }elseif($page!=="contact") {
print(bgcolor="#FFCC00") else ( print(bgcolor="#006699"); } ?>>

<td height="14" colspan="5"
valign="top"><!--DWLayoutEmptyCell-->&nbsp;</td>
</tr>

What happens is the View.php gets loaded into every page.
I have a cell the I would like to change the colour depending on what page
the user is on.
but would like to leave the other cells alone.

for example if($page!=="home") then the color (background color) of the cell
should be #006699
if the page isnot "home" but its ($page!=="registration") the color of that
cell should be #FF0000.
would this require the use of a variable? I have no clue how to use them.

Thanks

"Alvaro G Vicario" <alvaro_QUITAR_REMOVE@telecomputeronline.com> wrote in
message news:1mafccb0a87o8.qu1gi8t8br6a.dlg@40tude.net...
> *** Keith Mullin wrote/escribió (Thu, 6 Nov 2003 20:45:18 -0800):
> > If page is "home" Then cell colour should be blue
> > If page is "register" Then cell colour should be Red
> > If page is "contact us" Then cell colour should be yellow

>
> Do you mean something like...?
>
> <style>
> .blue{
> background-color: #89D3F8;
> }
> .red{
> background-color: #FEB7A5;
> }
> .yellow{
> background-color: #FFFFAA;
> }
> </style>
> <?
> switch($_SERVER['PHP_SELF']){
> case 'home.php':
> $style='blue';
> break;
> case 'register.php':
> $style='red';
> break;
> case 'contact.php':
> $style='yellow';
> break;
> }
> ?>
> <table><tr><td class="<?=$style">.......
>
>
> --
> --
> -- Álvaro G. Vicario - Burgos, Spain
> --



Reply With Quote
  #6 (permalink)  
Old 11-08-2003
Keith Mullin
 
Posts: n/a
Default Re: Cell Colour Change!!! WORKING CODE!!!!

I my Gosh I got it to work... Thank you so mutch for explaning how its
done.. it was ! in $page== that I needed to take out........
Here is the working code for future ref'

<tr bgcolor="#
<?php if($page=="compose") { print("66CC33"); }
elseif ($page=="registration") { print("FF0000"); }
elseif($page=="contact") { print("FFCC00"); }
else { print("006699"); } ?>">
<td height="14" colspan="5" valign="top"><!--DWLayoutEmptyCell-->&nbsp;</td>
</tr>

Thanks
k.M

"Pedro Graca" <hexkid@hotpop.com> wrote in message
news:bohciq$1emo9i$1@ID-203069.news.uni-berlin.de...
> Keith Mullin wrote:
> > This is what I have but does not work:
> >
> > <tr <?php if($page!=="home") { print(bgcolor="#006699"); }
> > elseif($page!=="compose") { print(bgcolor="#66CC33"); }
> > elseif($page!=="registration") {
> > print(bgcolor="#FF0000"); }elseif($page!=="contact") {
> > print(bgcolor="#FFCC00") else ( print(bgcolor="#006699"); } ?>>

>
> if ($page !== "home") { whatever }
>
> means:
>
> if the contents of the variable named $page are (very) *different* to
> "home" then do whatever
>
>
> I think you want
>
> if ($page === "home") { whatever }
>
> which means: if $page is (very) *equal* to "home" then do whatever
>
>
>
> But ... the switch solution provided by another poster is your best bet.
>
> switch ($page) {
> case 'home': echo 'bgcolor="#006699"'; break;
> case 'compose': echo 'bgcolor="#66CC33"'; break;
> // ...
> default: echo 'bgcolor="006699"';
> }
>
> did you notice the home and default colors are the same?
> get the "home" out of the construct to speed up your code a few
> milliseconds :)
>
> --
> .sig



Reply With Quote
Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are Off
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On




All times are GMT +1. The time now is 07:00 AM.


Powered by vBulletin® Version 3.7.3
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Content Relevant URLs by vBSEO 3.0.0