Jump to content

Quick Question


divinedesigns1
 Share

Recommended Posts

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?

  • Like 2
Link to comment
Share on other sites

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 by birbal
Link to comment
Share on other sites

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 by DDs1
Link to comment
Share on other sites

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 by niche
Link to comment
Share on other sites

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

$_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 by niche
Link to comment
Share on other sites

$_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

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 by niche
Link to comment
Share on other sites

if you are relying on only js then storing it in cookie would be the best

Link to comment
Share on other sites

if you are relying on only js then storing it in cookie would be the best
ok, 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

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.

  • Like 1
Link to comment
Share on other sites

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

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

I keep forgetting about those JS cookies http://www.w3schools.../js_cookies.asp Yum Yum
thanks, ill read that in a few
Link to comment
Share on other sites

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

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.

  • Like 1
Link to comment
Share on other sites

Is this still a "quick question" after 20 replies?
:Pleased: 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

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...

  • Like 1
Link to comment
Share on other sites

Guest So Called

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

Guest
This topic is now closed to further replies.
 Share

×
×
  • Create New...