Current location: Hot Scripts Forums » Programming Languages » PHP » Use of CSS within PHP


Use of CSS within PHP

Reply
  #1 (permalink)  
Old 07-11-05, 05:24 AM
CutAndPaste's Avatar
CutAndPaste CutAndPaste is offline
Newbie Coder
 
Join Date: Mar 2005
Location: London, UK
Posts: 52
Thanks: 0
Thanked 0 Times in 0 Posts
Use of CSS within PHP

Can anyone tell me the proper way to put in CSS info into a php echo? Not sure if this should go here or in CSS forum so please move if wrong.

I've got a little php expanding menu system which the links below are part of.

My CSS (part of)
PHP Code:

a:link,a:active,a:visited color #000000; }

a:hover        text-decorationunderlinecolor #757978; }
hr    height0pxbordersolid #D1D7DC 0px; border-top-width: 1px;}

.leftnavlv1 {
    
FONT-WEIGHTboldFONT-SIZE10pxCOLOR#333333; FONT-FAMILY: Verdana, Geneva, Arial, helvetica, sans-serif; TEXT-DECORATION: none
}
.
leftnavlv1:hover {
    
TEXT-DECORATIONunderline 
The code below is picking up the plain page link style and shows an underline on the link:
PHP Code:

echo '<a href=\"mypage.php?cpane=menu1\">Item 1</a>"'
BUT it mangles the URL which shows as:
Quote:
mydomain.com/\"mypage.php?cpane=menu1\"
The code below is picking up the leftnavlv1 style BUT is showing it with an underline all the time. The leftnavlv1 style does not show an underline elsewhere on the page, only when used as above.

PHP Code:

echo '<br><span class="leftnavlv1">',"<a href=\"mypage.php?cpane=menu1\">Item 1</a>",'</span>'
Elsewhere on the page I've got:
Code:
<a href="mypage.php" class="leftnavlv1">Home</a>
which works fine and picks up the CSS style properly.

What am I doing wrong?

thanks.
Reply With Quote
  #2 (permalink)  
Old 07-11-05, 05:33 AM
Lafa's Avatar
Lafa Lafa is offline
Newbie Coder
 
Join Date: Jul 2005
Location: Moss, Norway
Posts: 24
Thanks: 0
Thanked 0 Times in 0 Posts
first when you use the singel quatation mark ' ' you dont need to use backslashes. you just writeit like this:
PHP Code:

echo '<a href="mypage.php?cpane=menu1">Item 1</a>"'
so for the second link i dont see why you do this:
PHP Code:

<span class="leftnavlv1">',"<a 

with the singlequatation and then a comma and then a duble quotation mark.
this here should work:

PHP Code:

echo '<br><span class="leftnavlv1"><a href=\mypage.php?cpane=menu1">Item 1</a></span>'
__________________
TUXRocks, you dont.

Push it to the limit
Reply With Quote
  #3 (permalink)  
Old 07-11-05, 05:51 AM
CutAndPaste's Avatar
CutAndPaste CutAndPaste is offline
Newbie Coder
 
Join Date: Mar 2005
Location: London, UK
Posts: 52
Thanks: 0
Thanked 0 Times in 0 Posts
Lafa,
tx for the reply,

Unfortunately your suggested code still mangles the URL and the CSS is not picking up the style properly- it's bold but still underlined (should be bold and not underlined).

In case it has any bearing on the situation, this is the code in the menu I created. There is an include in mypage.php

PHP Code:

<?php

if(isset($_GET['cpane'])){
   switch(
$_GET['cpane']){
            
   case 
'calendar':
     include(
"includes/menu1.inc");
     break;
     
    case 
'calendar-item1':
     include(
"includes/menu2.inc");
     break;
     
        }
//end switch
            
}else{ // end if for cpane set
               
include("includes/homepage.inc");
    } 
// end else for cpane set
?>
Menu System
PHP Code:

echo '<a href=\"mypage.php?cpane=calendar\">Calendar</a>';

          echo 
'<br><span class="leftnavlv1">',"<a href=\"mypage.php?cpane=calendar\"></a>",'</span>';
              echo 
'<br><span class="leftnavlv1"><a href=\mypage.php?cpane=calendar">Item 1</a></span>'
            if(isset(
$_GET['cpane']) && preg_match('/^calendar/',$_GET['cpane']) ){
            
//Show sub menu
            
echo '<span class="leftnavlv1"><br><img src="images/bullet.gif" width="6" height="11">',"<a href=\"mypage.php?cpane=calendar-item1\">Item1</a>",'</span>'
thanks.
Reply With Quote
  #4 (permalink)  
Old 07-11-05, 06:05 AM
Lafa's Avatar
Lafa Lafa is offline
Newbie Coder
 
Join Date: Jul 2005
Location: Moss, Norway
Posts: 24
Thanks: 0
Thanked 0 Times in 0 Posts
does the CSS work in any way? i had problem if i used the
PHP Code:

echo '<head><link rel="css.css" type="text/css"></head>'
try using something like this:

PHP Code:

echo '<head><style type="text/css">' . include('css.css') . '</style></head>'
__________________
TUXRocks, you dont.

Push it to the limit
Reply With Quote
  #5 (permalink)  
Old 07-11-05, 06:07 AM
Lafa's Avatar
Lafa Lafa is offline
Newbie Coder
 
Join Date: Jul 2005
Location: Moss, Norway
Posts: 24
Thanks: 0
Thanked 0 Times in 0 Posts
and also
PHP Code:

 a:link,a:active,a:visited color #000000; }

a:hover        text-decorationunderlinecolor #757978; }
hr    height0pxbordersolid #D1D7DC 0px; border-top-width: 1px;}

.leftnavlv1 {
    
FONT-WEIGHTboldFONT-SIZE10pxCOLOR#333333; FONT-FAMILY: Verdana, Geneva, Arial, helvetica, sans-serif; TEXT-DECORATION: none
}
.
leftnavlv1:hover {
    
TEXT-DECORATIONunderline 
last lines states that it is underline, but if you want it right try a ';' and a '}' at the end to.
__________________
TUXRocks, you dont.

Push it to the limit
Reply With Quote
  #6 (permalink)  
Old 07-11-05, 07:27 AM
CutAndPaste's Avatar
CutAndPaste CutAndPaste is offline
Newbie Coder
 
Join Date: Mar 2005
Location: London, UK
Posts: 52
Thanks: 0
Thanked 0 Times in 0 Posts
thanks,

The problem is NOT that the CSS is not appearing at all, but that it is not displaying consistently.

I'm just trying to get a style that displays ok on the rest of the page to display in the same way from inside a php echo.

I can get it LOOK nearly OK (though still with the unwanted underline text decoration), BUT it then mangles the php code for the link URL.
Reply With Quote
Reply

Bookmarks


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
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 On
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
PHP Downside--Solutions? Amulet PHP 10 07-15-05 08:26 AM
PHP multi-dimensional array sorting issue aqw PHP 2 06-24-05 11:09 PM
[FOR HIRE] (x)html, css, php, mysql, designing JeanM Job Offers & Assistance 0 04-11-05 09:44 AM
PHP and CSS Expert NEEDED!!!! eFutureMedia Job Offers & Assistance 1 09-11-04 01:53 PM
PHP and CSS Expert NEEDED!!!! eFutureMedia PHP 4 09-11-04 08:34 AM


All times are GMT -5. The time now is 06:54 AM.
vBulletin® Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.