newmedia Posted March 10, 2006 Share Posted March 10, 2006 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 suggestionsTim Quote Link to comment https://forums.phpfreaks.com/topic/4617-change-stylesheet-ref-depending-on-session-id/ Share on other sites More sharing options...
mem0ri Posted March 10, 2006 Share Posted March 10, 2006 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 Link to comment https://forums.phpfreaks.com/topic/4617-change-stylesheet-ref-depending-on-session-id/#findComment-16225 Share on other sites More sharing options...
newmedia Posted March 10, 2006 Author Share Posted March 10, 2006 [!--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 Quote Link to comment https://forums.phpfreaks.com/topic/4617-change-stylesheet-ref-depending-on-session-id/#findComment-16264 Share on other sites More sharing options...
txmedic03 Posted March 11, 2006 Share Posted March 11, 2006 <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. Quote Link to comment https://forums.phpfreaks.com/topic/4617-change-stylesheet-ref-depending-on-session-id/#findComment-16295 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.