title: Dynamic Database Driven CSS
body: <p>Here is my problem, I have a site I am building. I am including an admin page to manage everything on the fly, that i have no issue with as it is pretty straight forward php, mysql etc. I have it in my head that i can use a database to store css and  dynamically call it up as i add new setting for the different classes, id's etc. my table is this:
  settings
  id--class--div--setting</p>
  
  <p>Where class is something like body, header, footer, etc. and div and setting are as follows:</p>
  
  <pre><code>.header {
  $div:$setting;
  }
  </code></pre>
  
  <p>in my script i am echoing the style tag and including this inside of the head tags.</p>
  
  <p>my code for what it is worth is below:</p>
  
  <pre><code>$header_query = mysql_query("SELECT style, setting FROM styles WHERE class='header'");
  $header_result = mysql_fetch_array($header_query);
  
  
  echo "&lt;style type='text/css'&gt;";
  echo ".header {";
     foreach($header_result as $hstyle =&gt; $hsetting){
     echo $hstyle.":".$hssetting.";";
     }
  
     echo "}";
     echo "&lt;/style&gt;";
  </code></pre>
  
  <p>I figgured that would be enough to echo each setting for that particular class and I was right in part. Instead of echoing out the desired code my echo(depending on the mysql_fetch command i use) spits out something like this:</p>
  
  <pre><code>&lt;style&gt;
  .header {
  0:div;1:background;2:setting;3:url(x.jpg)
  }
  &lt;/style&gt;
  </code></pre>
  
  <p>Any ideas, I'm stumped?</p>