Ok so I’m trying to make a basic style switcher I store which style the user is using in side a mysql db then I echo it out and pick the css but I’m having a problem when I echo it out I echo out pink then I add the .css out of php but says it can’t find the css when it’s there…
Here is my code
<?php
include 'config.php';
$sql = "SELECT * FROM users WHERE username='$_SESSION[username]'";
$result = mysql_query($sql) or die(mysql_error());
$battle_get = mysql_fetch_array($result);
?>
<link rel="stylesheet" type="text/css" href="items.php_files/<?php echo $battle_get['style'] ; ?>.css" media="screen">
Maybe there is a space some were ?? in the echo ?? I echo out the $battle_get['style'] and get what I need e.g pink then I try and echo it out in side the html with css on the end but does not work…
change it to
$sql = "SELECT * FROM users WHERE username='{$_SESSION['username']}'";and if you are only using style from the user table, just do
$sql = "SELECT style FROM users WHERE username='{$_SESSION['username']}'";for the link, use this instead
<link rel="stylesheet" type="text/css" href="items.php_files/<?php echo trim($battle_get['style']); ?>.css" media="screen">