Jump to content


Photo

Multiple ?id=1


  • Please log in to reply
6 replies to this topic

#1 XeroXer

XeroXer
  • Members
  • PipPipPip
  • Advanced Member
  • 80 posts
  • LocationSweden

Posted 02 August 2006 - 02:25 PM

Hi there.

I am making a page where I want the user to be able to specify what look they want the page in.
So that on the startpage there shall be different colored squares that they can click.
And if they click the red one the design pick my red.css file to use.
By doing this I use the ?css=1 and different numbers.
Thought that creates a problem.

I use the ?id=1 to choose what page to show.
How do I do so that I can have more of these :-)...
I have seen pages using index.php?id=1&?css=3.
Is this easy to do or?

Or maybe someone has a different idea on how to do the style switching?
Maybe using cookies so that if they return to the page the style they chose is still used.
Please post any tips you can think of...
// XeroXer

#2 Ifa

Ifa
  • Members
  • PipPipPip
  • Advanced Member
  • 88 posts
  • LocationRauma, Finland

Posted 02 August 2006 - 02:27 PM

<a href="index.php?id=1&amp;css=1">
That's one way of doing it, and the easiest...
And you can also do a cookie thing so that the style will remain for the next visit.

I'm just a guy who likes to code for fun...

#3 XeroXer

XeroXer
  • Members
  • PipPipPip
  • Advanced Member
  • 80 posts
  • LocationSweden

Posted 02 August 2006 - 02:49 PM

But if I use cookies to save the theme they selected do I still need ?css=1 or can I make it any other way?
// XeroXer

#4 DaveLinger

DaveLinger
  • Members
  • PipPipPip
  • Advanced Member
  • 268 posts
  • LocationWV, USA

Posted 02 August 2006 - 02:50 PM

you'd just save the cookie when they pick the stylesheet, and load it when they load a page.
http://www.DaveLinger.com
dave at linger dot com

#5 XeroXer

XeroXer
  • Members
  • PipPipPip
  • Advanced Member
  • 80 posts
  • LocationSweden

Posted 02 August 2006 - 03:00 PM

Ok!
How do I create a link that saves a cookie with the color information and then reloades the site to show the color they chose?
All the questions is because the first time I ever used cookies with a php script was yesterday. :-)

Because this would work to chek it right?
<head>
<?php
$css = "$_COOKIE[css]";
if $css == "red" { $stylecss = "style_red.css"; }
elseif $css == "blue" { $stylecss = "style_blue.css"; }
elseif $css == "green" { $stylecss = "style_green.css"; }
elseif $css == "brown" { $stylecss = "style_brown.css"; }
else { $stylecss = "style.css"; }
?>
<link href="<?php echo $stylecss; ?>" rel="stylesheet" type="text/css">
</head>

I know that I can use:
<?php 
setcookie("css", "red", time()+36000);
?>
but not how to embed it into a link...
// XeroXer

#6 ryanlwh

ryanlwh
  • Staff Alumni
  • Advanced Member
  • 511 posts

Posted 02 August 2006 - 04:06 PM

just put that setcookie on top of a page that you will link to. say you have a link "changestyle.php?css=red", then on that changestyle.php page you can do
<?php
setcookie('css',$_GET['css'],time()+36000);
header('Location: index.php');
?>
you can also make a dropdown list and a form for them to change the theme.
Please use EDIT * 100...
Please use
or [php] * 1000...

PLEASE READ THE POSTED SOLUTIONS CAREFULLY * 1000000...

#7 Ifa

Ifa
  • Members
  • PipPipPip
  • Advanced Member
  • 88 posts
  • LocationRauma, Finland

Posted 02 August 2006 - 04:11 PM

And it's $css = $_COOKIE['css'];

I'm just a guy who likes to code for fun...




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users