Jump to content

Archived

This topic is now archived and is closed to further replies.

newmedia

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

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

Share this post


Link to post
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.

Share this post


Link to post
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

Share this post


Link to post
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.

Share this post


Link to post
Share on other sites

×

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.