[SOLVED] Dynamic CSS from mySQL
Posted: Sun Jun 27, 2004 8:48 am
hey to all,
i am developing an app that is basicaaly a frontend to a database, i would however like tyo be able to customise the CSS that maintains the whole of this app.
rather than having *alot* of tables i thought i would have one table per section
such as a table with tuples for the menu colours and text colours etc.,
anyways to avoid heaps of tables i thought i would still have a css file and have it read in and modified according to the query from the database.
therefore on startup it will show default values and when changed via a settings page, then upon a refresh it will reflect the new changes that have been made in the css file. the same file just with modified values.
anyways using this approach im trying to do a reg replace and it doesnt work :S
i thought if i added a comment to prefix what i wanted to change and have the preifx the same as the attribute name it would be very easier, but not so far it isnt.
any ideas pls --> i think eventually i will use preg_replace, however i may need some help on the pattern syntax there
CSS snippet:
any ideas other than this would be apprecated 
kind regards,
g00fy
i am developing an app that is basicaaly a frontend to a database, i would however like tyo be able to customise the CSS that maintains the whole of this app.
rather than having *alot* of tables i thought i would have one table per section
such as a table with tuples for the menu colours and text colours etc.,
anyways to avoid heaps of tables i thought i would still have a css file and have it read in and modified according to the query from the database.
therefore on startup it will show default values and when changed via a settings page, then upon a refresh it will reflect the new changes that have been made in the css file. the same file just with modified values.
anyways using this approach im trying to do a reg replace and it doesnt work :S
i thought if i added a comment to prefix what i wanted to change and have the preifx the same as the attribute name it would be very easier, but not so far it isnt.
any ideas pls --> i think eventually i will use preg_replace, however i may need some help on the pattern syntax there
Code: Select all
function searchCSSFile($search, $file = 'css/global.css'){
if (file_exists($file)){
$contents = @ file_get_contents($file);
if ($contents != false){
echo 'looking for: ' . $search.'<br>';
if (ereg($search, $contents)){
// just trying to find it at the moment
// work on replace later
echo $search . ' Found In File... ' . $file;
}
else{
echo $search . ' Not Found In File... ' . $file;
}
}
else{
echo 'Can''t open: ' . $file . "\n";
}
}
else{
echo $file . "Doesn't exist. \n";
}
return $match;
}
searchCSSFile("/*menu_text_col*/ color:");Code: Select all
/*menu_text_col*/color: #666666;kind regards,
g00fy