Ok, so I am trying to improve on my previous question about dynamic CSS driven by a MYSQL database. i have gotten this to work for one CSS class but not for more than one. What i am trying to do is put one while statement inside of another. my database consists of this at present:
table styles
id - class - style - setting - page
1 header width 1000px index
2 header height 200px index
3 footer width 1000px index
my code is as follows:
$pname = $_SERVER['REQUESTED_URI'];
$class_query = mysql_query("SELECT DISTINCT(class) AS class FROM styles WHERE pname='".$pname."'");
$style_query = mysql_query("SELECT style, setting FROM styles WHERE pname='".$pname."' AND class='".$class_result['class']."'");
echo "<style>";
while($class_result_row = mysql_fetch_array($class_query,MYSQL_ASSOC)) {
echo ".".$class_result_row['class']."{";
while($style_result_row = mysql_fetch_array($style_query,MYSQL_ASSOC)) {
echo $style_result_row['style'].":".$style_result_row['setting'].";";
}
echo "}";
}
echo "</style>";
This works great for the index content but it does not show the footer styles. The main difference between this and what I had previously asked here is that instead of manually setting up the same script for each and every page to load the page specific content I want to wrap this in a function and call it once in the header and be done with it. i also have tried to set a $GLOBALS and $SESSION variable for the page name but the results are the same. on a side note i also used the variables without the extra quotes and periods and got the same results too. thanks in advance everyone! --John