cheechm Posted March 16, 2008 Share Posted March 16, 2008 Hi, Would it be possible to create a .css from data in a MySQL Table. Simply say I had three rows: Name Width Height .page 500px 100px Could I put that into a .css? Hope you understand. Thanks Link to comment https://forums.phpfreaks.com/topic/96333-creating-a-css/ Share on other sites More sharing options...
Barand Posted March 16, 2008 Share Posted March 16, 2008 <?php /** * if reading from a db you have */ $row = array ( 'Name' => '.page', 'Width' => '500px', 'Height' => '100px' ); /** * write it to a css file */ $str = $row['Name'] . " {\n" ; unset ($row['Name']); // lose "name". The rest are attributes foreach ($row as $attr => $val) { $str .= "\t$attr: $val;\n"; } $str .= "}\n\n"; //file_put_contents('my.css', $str); // uncomment to write to file echo '<pre>', $str, '</pre>'; // see what would be written ?> Link to comment https://forums.phpfreaks.com/topic/96333-creating-a-css/#findComment-493121 Share on other sites More sharing options...
cheechm Posted March 16, 2008 Author Share Posted March 16, 2008 Many thanks. Link to comment https://forums.phpfreaks.com/topic/96333-creating-a-css/#findComment-493123 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.