Connecting Tech Pros Worldwide Help | Site Map

background color (Help)

Member
 
Join Date: Mar 2008
Posts: 72
#1: Aug 24 '09
i have a form as below where by default its background color is white

________
Name:
Address:

Activities:
Year:
Service:
_______

My question is how to change its portion of background color from white to pink? e.g. the background for Name and Address remain as white while starting from activities till service their background color will be pink?

Thanks
code green's Avatar
Expert
 
Join Date: Mar 2007
Location: England
Posts: 1,076
#2: Aug 24 '09

re: background color (Help)


<div class="classname of css with bgcolor:pink>
Member
 
Join Date: Mar 2008
Posts: 72
#3: Aug 24 '09

re: background color (Help)


Quote:

Originally Posted by code green View Post

<div class="classname of css with bgcolor:pink>

Hi, thanks for your reply. I am totally new to php.
what is the "classname of css with bgcolor" ??

is it i need to put the above code that given by you before the Activities??
Thanks.
dheerajjoshim's Avatar
Familiar Sight
 
Join Date: Jul 2009
Location: Bangalore, INDIA
Posts: 245
#4: Aug 24 '09

re: background color (Help)


CSS(Cascaded style sheet) it allows you to set the visual effects of your page...
(Like back ground color, font,size etc etc).

it has got nothing to do with PHP.

what code green meant was change external CSS file(Assuming you used one).
If you havent used. Create one.

You refere w3schools for help regarding CSS.

Regards
Dheeraj Joshi
Member
 
Join Date: Mar 2008
Posts: 72
#5: Aug 24 '09

re: background color (Help)


Quote:

Originally Posted by dheerajjoshim View Post

CSS(Cascaded style sheet) it allows you to set the visual effects of your page...
(Like back ground color, font,size etc etc).

it has got nothing to do with PHP.

what code green meant was change external CSS file(Assuming you used one).
If you havent used. Create one.

You refere w3schools for help regarding CSS.

Regards
Dheeraj Joshi

Thanks.


i learnt that basically i need to insert

Expand|Select|Wrap|Line Numbers
  1. <style type="text/css">
  2. mybackground
  3. {
  4. background-color:#e0ffff;
  5. }
  6. </style>
between the

Expand|Select|Wrap|Line Numbers
  1. <html>
  2. <head>
  3.  
  4. </html>
  5. </head>
but now my problem is... i cant find the header in my web (myweb.php)


my web starting with something as below

Expand|Select|Wrap|Line Numbers
  1. <?php
  2.  
  3. class HTML_myweb
  4. {
  5.     function thankyou($option){
  6. ?>
  7.  
  8. <?php        
  9.     }
  10.     function show_form($option)
  11.     {
  12. ?>
  13.             <style>
  14.                 div#registerBox fieldset .redd{
  15.                     color:#ff0000;
  16.                 }
  17.             </style>
  18.  
  19. /* i add my css class here */
  20.  
  21.                    <style type="text/css">
  22.                    mybackground
  23.                      {
  24.                    background-color:#e0ffff;
  25.                     }
  26.                    </style>
  27.  
  28.  
  29. <p><label>Name:<span class="redd">*</span></label><input type="text" name="name" id="name" /></p>
  30. <p><label>Address:<span class="redd">*</span></label><input type="text" name="address" id="address" /></p>
  31.  
  32. /* i would like to change my background start from the line below */
  33. <mybackground>
  34. <p><label>Activities:<span class="redd">*</span></label><input type="text" name="activities" id="activities" /></p>
  35. <p><label>Year:<span class="redd">*</span></label><input type="text" name="year" id="year" /></p>
  36. <p><label>Service:<span class="redd">*</span></label><input type="text" name="service" id="service" /></p>
  37. </mybackground>
but when i try to run the code.. the form still the same ..nothing changed.
please guide
dheerajjoshim's Avatar
Familiar Sight
 
Join Date: Jul 2009
Location: Bangalore, INDIA
Posts: 245
#6: Aug 25 '09

re: background color (Help)


Header may look like this

Expand|Select|Wrap|Line Numbers
  1. <?php
  2. echo "<html>";
  3. header('Location: http://www.example.com/path/to/file');
  4. echo "</html>";
  5. ?>
  6.  
This is how your header must look like....

You can embed HTML code within PHP tag.. and just echo it.... or other way round.

Regards
Dheeraj Joshi
Dormilich's Avatar
Moderator
 
Join Date: Aug 2008
Location: Leipzig, Germany
Posts: 3,621
#7: Aug 25 '09

re: background color (Help)


the php code you have shown should throw an error.
dheerajjoshim's Avatar
Familiar Sight
 
Join Date: Jul 2009
Location: Bangalore, INDIA
Posts: 245
#8: Aug 25 '09

re: background color (Help)


What error?

I remember once i used above code.. It didnot gave any error... What error you are talking about.?

Following must also work....

Expand|Select|Wrap|Line Numbers
  1. <?php
  2. header("  ");
  3. ?>
  4.  
Member
 
Join Date: Mar 2008
Posts: 72
#9: Aug 25 '09

re: background color (Help)


Hi Dormilich and dheerajjoshim,
when i insert the code.. i got NO error on that. Just the background color didnt change.
i search through the code i didnt find the "header" nor the " echo"
Dormilich's Avatar
Moderator
 
Join Date: Aug 2008
Location: Leipzig, Germany
Posts: 3,621
#10: Aug 25 '09

re: background color (Help)


Quote:

Originally Posted by dheerajjoshim View Post

What error?

I’d expect a ‘missing } error’. and as a personal note, I wouldn’t use a class for simple text, an include should work good enough.
Atli's Avatar
Moderator
 
Join Date: Nov 2006
Location: Iceland
Posts: 3,731
#11: Aug 30 '09

re: background color (Help)


A bit late on this, but...

The code posted by Dheeraj would in fact not work as expected.
The header function adds a header to the HTTP response, and has nothing to do with the HTML <header> tag.
And seeing as you put an echo call right before it, it would never even get executed. (HTTP headers can't be manipulated once content is added to the response.)

Doing header("Location: file.txt"); would not include a header into the current HTML source. It would redirect you to the "file.txt" file. (Which I assume is not what you wanted to happen.)

I'm not entirely sure what you are doing with that "HTML_myweb" class, MyMarlboro, but it seems a bit to complex for this particular problem.

The solution is pretty simple, actually.
Expand|Select|Wrap|Line Numbers
  1. <!-- file: index.html -->
  2. <html>
  3. <head>
  4.     <style type="text/css">
  5.         .bnw {
  6.             background-color: #ffffff;
  7.             color: #000000;
  8.         }
  9.         .wnb {
  10.             background-color: #000000;
  11.             color: #ffffff;
  12.         }
  13.     </style>
  14. </head>
  15. <body>
  16.     <p class="bnw">Black text, white background</p>
  17.     <p class="wnb">White text, black background</p>
  18. </body>
  19. </html>
Or, if you prefer to put the CSS into an external file:
Expand|Select|Wrap|Line Numbers
  1. /* file: styles.css */
  2. .bnw {
  3.     background-color: #ffffff;
  4.     color: #000000;
  5. }
  6. .wnb {
  7.     background-color: #000000;
  8.     color: #ffffff;
  9. }
Expand|Select|Wrap|Line Numbers
  1. <!-- file: index.html -->
  2. <html>
  3. <head>
  4.      <link rel="stylesheet" href="styles.css" media="all">
  5. </head>
  6. <body>
  7.     <p class="bnw">Black text, white background</p>
  8.     <p class="wnb">White text, black background</p>
  9. </body>
  10. </html>
None of that has anything to do with PHP. It's just HTML and CSS.
Reply