divinedesigns1 Posted June 11, 2012 Share Posted June 11, 2012 hey, i manage to make the effect of switching between the style sheets, but how can i make it stay as the main stylesheet for the whole site, even if you go to another page, i can make it switch from default to the other stylesheet, but when i click on another page it return to the default page. is there a way to make it stay on the other page even if i click on another page? 2 Link to comment Share on other sites More sharing options...
birbal Posted June 11, 2012 Share Posted June 11, 2012 (edited) you can use session to store the stylesheet name in session across pages. if you want it to remain same across session you can use cookies or in database(user specific stylesheet) Edited June 11, 2012 by birbal Link to comment Share on other sites More sharing options...
divinedesigns1 Posted June 11, 2012 Author Share Posted June 11, 2012 (edited) ok, so just do start_session(stylesheet); ? also can i do in a select query,$query = "SELECT news(id, title, post, DATE_FORMAT(date, '%m %d, %y')) WHERE $id='id'"; Edited June 11, 2012 by DDs1 Link to comment Share on other sites More sharing options...
niche Posted June 11, 2012 Share Posted June 11, 2012 (edited) More like $_SESSION['stylesheet'] = You were close. EDIT: session_start(); initializes the $_SESSION array. And, session_write_close(); is used at the end of the script. Edited June 11, 2012 by niche Link to comment Share on other sites More sharing options...
divinedesigns1 Posted June 11, 2012 Author Share Posted June 11, 2012 More like $_SESSION['stylesheet'] = You were close. EDIT: session_start(); initializes the $_SESSION array. And, session_write_close(); is used at the end of the script.can you show me an explain? and how would that work with javascript? Link to comment Share on other sites More sharing options...
niche Posted June 11, 2012 Share Posted June 11, 2012 (edited) $_SESSION is a creature of php. http://php.net/manua...es.sessions.php So, I'd do a ajax call. However, I'd try to avoid javascript, unless necessary, and just work with php. Edited June 11, 2012 by niche Link to comment Share on other sites More sharing options...
divinedesigns1 Posted June 11, 2012 Author Share Posted June 11, 2012 $_SESSION is a creature of php. http://php.net/manua...es.sessions.php So, I'd do a ajax call. However, I'd try to avoid javascript, unless necessary, and just work with php.sorry im working with javascript to switch my stylesheet Link to comment Share on other sites More sharing options...
niche Posted June 11, 2012 Share Posted June 11, 2012 (edited) The only way I know how to get JS data into a php variable is through an ajax call. You probably should do this tutorial if you haven't already. http://www.w3schools..._ajax_intro.asp Edited June 11, 2012 by niche Link to comment Share on other sites More sharing options...
birbal Posted June 11, 2012 Share Posted June 11, 2012 if you are relying on only js then storing it in cookie would be the best Link to comment Share on other sites More sharing options...
niche Posted June 11, 2012 Share Posted June 11, 2012 I have to ask. Why? Link to comment Share on other sites More sharing options...
divinedesigns1 Posted June 11, 2012 Author Share Posted June 11, 2012 if you are relying on only js then storing it in cookie would be the bestok, how do you store js code into a cookie? ok i have a lot to look up, thanks birbal Link to comment Share on other sites More sharing options...
birbal Posted June 11, 2012 Share Posted June 11, 2012 you dont need to store js code in cookie. you have to specify the file name of it in the cookie.and you will use it to alter the file location later. if cookie is not there you can fallback to default stylesheet. 1 Link to comment Share on other sites More sharing options...
divinedesigns1 Posted June 11, 2012 Author Share Posted June 11, 2012 you dont need to store js code in cookie. you have to specify the file name of it in the cookie.and you will use it to alter the file location later. if cookie is not there you can fallback to default stylesheet.ok thank you, ill do some research and try it out Link to comment Share on other sites More sharing options...
niche Posted June 11, 2012 Share Posted June 11, 2012 (edited) I keep forgetting about those JS cookies http://www.w3schools.../js_cookies.asp Yum Yum EDIT: Great save birbal. Edited June 11, 2012 by niche Link to comment Share on other sites More sharing options...
birbal Posted June 11, 2012 Share Posted June 11, 2012 https://developer.mozilla.org/en/DOM/Storage dont want to make you confused but so that you know, you may like to check localstorage too. it is same like cookie (store name value pair) but does not go back and forth with every page request. it is new in html5. Link to comment Share on other sites More sharing options...
divinedesigns1 Posted June 11, 2012 Author Share Posted June 11, 2012 I keep forgetting about those JS cookies http://www.w3schools.../js_cookies.asp Yum Yumthanks, ill read that in a few Link to comment Share on other sites More sharing options...
divinedesigns1 Posted June 11, 2012 Author Share Posted June 11, 2012 https://developer.mo.../en/DOM/Storage dont want to make you confused but so that you know, you may like to check localstorage too. it is same like cookie (store name value pair) but does not go back and forth with every page request. it is new in html5.will check that out too, soon as i look over these typos Link to comment Share on other sites More sharing options...
Ingolme Posted June 11, 2012 Share Posted June 11, 2012 I see no problem with using Javascript to change the stylesheet. It's not one of the things that's absolutely necessary for the user, so PHP isn't a requirement. The site will still work just fine when Javascript is disabled. I've done stylesheet switchers before, and I always use cookies. If you have user accounts and you really want to, you can then send an AJAX request to PHP to save the user's stylesheet selection. 1 Link to comment Share on other sites More sharing options...
niche Posted June 11, 2012 Share Posted June 11, 2012 There you go Ingolme. If you're going to change the whole page use server side. Link to comment Share on other sites More sharing options...
Guest So Called Posted June 11, 2012 Share Posted June 11, 2012 Is this still a "quick question" after 20 replies? Link to comment Share on other sites More sharing options...
niche Posted June 11, 2012 Share Posted June 11, 2012 Quick questions can frequently have the longest answers. 3 Link to comment Share on other sites More sharing options...
divinedesigns1 Posted June 12, 2012 Author Share Posted June 12, 2012 Is this still a "quick question" after 20 replies? yes it is still a quick question, since i have gotten my answer and a few references so yes it is still a quick question. Link to comment Share on other sites More sharing options...
Guest So Called Posted June 12, 2012 Share Posted June 12, 2012 What is the subject of this topic? Link to comment Share on other sites More sharing options...
thescientist Posted June 12, 2012 Share Posted June 12, 2012 Clearly he is getting the help he needs (references, opinions, suggestions, etc), from people who were able to read his post. Maybe his topic title is vague, but his post/question is pretty clear. Were you planning on adding anything to conversation yourself, cause it seems like this thread could have been two posts shorter... 1 Link to comment Share on other sites More sharing options...
Guest So Called Posted June 12, 2012 Share Posted June 12, 2012 Maybe every topic should be titled "quick question" so that people can get the help they need (references, opinions, suggestions, etc). Maybe putting the subject of the topic in the subject line has become old fashioned. Link to comment Share on other sites More sharing options...
Recommended Posts