Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7953043
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 4, 20262026-06-04T03:02:41+00:00 2026-06-04T03:02:41+00:00

Ok, so I am trying to improve on my previous question about dynamic CSS

  • 0

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

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-04T03:02:43+00:00Added an answer on June 4, 2026 at 3:02 am

    I think you have to execute your style query every time you iterate through the class query results. Try something like:

    $pname = $_SERVER['REQUESTED_URI'];
    $class_query = mysql_query("SELECT DISTINCT(class) AS class FROM styles WHERE pname='".$pname."'");
    echo "<style>";
    while($class_result_row = mysql_fetch_array($class_query,MYSQL_ASSOC))  {
        echo ".".$class_result_row['class']."{";
        $style_query = mysql_query("SELECT style, setting FROM styles WHERE pname='".$pname."' AND class='".$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>";
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm trying to improve my mouse event knowledge so this question is about why
I am always trying to improve my programming practices and this one habit of
I'm trying to improve a legacy database. One problem is that it's missing a
I am currently trying to improve on an Access Database VBA that I have
I am trying to improve an external sort implementation in java. I have a
I'm trying to improve this plugin adding events handlers to toggle play/stop when you
I'm trying to improve my current algorithm for the 8 Queens problem, and this
trying to improve my question asking etiquette, so I'll state my aim, ask my
Im am trying to improve a ToDo app for the iPhone. I have two
We are currently trying to improve our usability in our intranet web app. One

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.