Hello, I am trying to create something that allows a user to select a stylesheet, and to have that stylesheet permanantly used, so it is remembered wqhen they log out and called when they log back in. I have 90% of the code sorted, the following code will let the user select a color, write it to the users "color" field in the database, and then load in the relevant stylesheet based on the radio buttons selection. However i need it to call from the database and replace the current stylesheet with whichever color is present in the db at all times, so that when the user is logged out the styleshhet prefernce is remembered, and called when they re-log in. Any ideas? here is my code and its the last statement i cant seem to get right :
Thankyou in advance for any help
Dan
PHP Code:
<?php include("include/session.php");?>
<?php
if (isset($_POST['Submit1'])) {
$selected_radio = $_POST['color'];
print $selected_radio;
} ?>
<html>
<head>
<title>My Page</title>
<?php
$css1 = "SELECT `color` WHERE `users`.`username` = '$session->username' LIMIT 1 ";
$red_status = 'unchecked';
$blue_status = 'unchecked';
$green_status = 'unchecked';
if (isset($_POST['Submit1'])) {
$selected_radio = $_POST['color'];
if ($selected_radio == 'red') {
$qry= "UPDATE `users` SET `color` = 'red' WHERE `users`.`username` = '$session->username' LIMIT 1 ";
$red_status = 'checked';
echo "<link href=\"css/red.css\" media=\"all\" rel=\"stylesheet\" type=\"text/css\">";
}
else if ($selected_radio == 'blue') {
$qry= "UPDATE `users` SET `color` = 'blue' WHERE `users`.`username` = '$session->username' LIMIT 1 ";
$blue_status = 'checked';
echo "<link href=\"css/blue.css\" media=\"all\" rel=\"stylesheet\" type=\"text/css\">";
}
else if ($selected_radio == 'green') {
$qry= "UPDATE `users` SET `color` = 'green' WHERE `users`.`username` = '$session->username' LIMIT 1 ";
$green_status = 'checked';
echo "<link href=\"css/green.css\" media=\"all\" rel=\"stylesheet\" type=\"text/css\">";
} else (
*// this is the line i cant seem to get right
echo " <link rel=\"stylesheet\" type=\"text/css\" href=\"css/\""; echo "$css1"; echo"\">";?>
)
$result = mysql_query($qry);
}
?>
Dan
Comment