Jump to content

change stylesheet ref depending on session id ??????


newmedia

Recommended Posts

Is there any way of changing the way a MySQL record is displayed (using css) depending on its row $id ?

i tried to add the stylesheet href ($style) to each row in the databasese and incorporate that in the pages header :

<link rel="stylesheet" type="text/css" href="../assets/<?php echo "$style" ?id=$id" ?>">

I'm thinking this didnt work for loads of resons.

I'm no expert as you might have gathered.


..so just to clarify,

I need my dynamic form to display the data differently, depending on the row id / session id .

Any suggestions

Tim
Link to comment
Share on other sites

Changing by session id, simply save the preferred CSS style into the database with the user (I'm assuming there is a user database...). Once the user logs in, the header href can point to the correct stylesheet by a php variable in the link path.

Changing by row...like if you want alternating row colors or whatever...simply determine if the current row is dividable by two...and if so, run one style...if not, run the other. No separate stylesheet is needed, simply only two style classes.
Link to comment
Share on other sites

[!--quoteo(post=353723:date=Mar 10 2006, 04:10 PM:name=mem0ri)--][div class=\'quotetop\']QUOTE(mem0ri @ Mar 10 2006, 04:10 PM) [snapback]353723[/snapback][/div][div class=\'quotemain\'][!--quotec--]
Changing by session id, simply save the preferred CSS style into the database with the user (I'm assuming there is a user database...). Once the user logs in, the header href can point to the correct stylesheet by a php variable in the link path.

Changing by row...like if you want alternating row colors or whatever...simply determine if the current row is dividable by two...and if so, run one style...if not, run the other. No separate stylesheet is needed, simply only two style classes.
[/quote]

great. but i tried that and it didnt work. maybe I need to place the stylesheet reference after the 'connect to database' commands on the page. any thoughts.? thanks
Link to comment
Share on other sites

<link rel="stylesheet" type="text/css" href="stylesheet.css" />

This goes in the <head></head> of the page. One reference to one stylesheet is all that is required. If you are alternating rows then a class for your rows:

.rowodd {
background-color: #FFF;
}

.roweven {
background-color: #CCC;
}

If you need more information on CSS and how it works then you might consider adding [a href=\"http://www.w3schools.com/css/\" target=\"_blank\"]W3Schools[/a] to your favorites. It is an excellent resource and will explain things a lot better than my short replies. If you are still stuck, I am happy to help.
Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.