Dynamic Database Driven CSS -
here problem, have site building. including admin page manage on fly, have no issue pretty straight forward php, mysql etc. have in head can use database store css , dynamically call add new setting different classes, id's etc. table this: settings id--class--div--setting
where class body, header, footer, etc. , div , setting follows:
.header { $div:$setting; }
in script echoing style tag , including inside of head tags.
my code worth below:
$header_query = mysql_query("select style, setting styles class='header'"); $header_result = mysql_fetch_array($header_query); echo "<style type='text/css'>"; echo ".header {"; foreach($header_result $hstyle => $hsetting){ echo $hstyle.":".$hssetting.";"; } echo "}"; echo "</style>";
i figgured enough echo each setting particular class , right in part. instead of echoing out desired code echo(depending on mysql_fetch command use) spits out this:
<style> .header { 0:div;1:background;2:setting;3:url(x.jpg) } </style>
any ideas, i'm stumped?
mysql_fetch_array
fetches 1 row. may use
$header_query = mysql_query("select style, setting styles class='header'"); echo "<style type='text/css'>"; echo ".header {"; while($header_result_row = mysql_fetch_array($header_query,mysql_assoc)) echo $header_result_row['style'].":".$header_result_row['setting'].";"; echo "}"; echo "</style>";
almost mysql_fetch_*
affecting single row, keep in mind. see mysql_fetch_array
examples.
Comments
Post a Comment