Register

If this is your first visit, please click the Sign Up now button to begin the process of creating your account so you can begin posting on our forums! The Sign Up process will only take up about a minute of two of your time.

Results 1 to 6 of 6
  1. #1
    Junior Member blondegeek's Avatar
    Join Date
    Jul 2007
    Posts
    7
    Member #
    15559
    Hello there!
    I've been working on a new section for my website and I finally have all the technical php down but alas I can't seem to get the CSS to work if it's generated by PHP. I've looked up pages about using PHP to create CSS but they never mention anything about actually using database info to plug into the CSS. Can this be done? I tried adding the:
    Code:
     header('Content-type: text/css');
    to the original projects.php but I got an error saying that the header couldn't be altered or something vague (in my opinion) like that. Soo....I thought that I would just dump all the css/php/mysql goodness into a file called projectcss.php and reference it as a css file. I did and it didn't work (or else I would not be writing this).

    Here are the urls for my files:
    The main page
    The oh so not cooperative css page

    Code for the css/php pages thus follows: (with database info deleted)
    Code:
    <?
    header('Content-type: text/css');
    
    
    
    ////////////
        $sql=mysql_query("SELECT * FROM `projects_titles`");
        $query = mysql_num_rows($sql);
        $total = $query+2;
    
    
    for($i = 0; $query >= $i; $i++){
    $a = $i+1;
    $top = $i*110+225;
    echo "#".$a." {\n" . "top: ".$top."px;"."\n"."left: 160px;\n}\n";}
    
    
    for($i = 0; $total >= $i; $i++){
    $b = $i+1;
    $top2 = $i*110+100;
    echo "".$b." {\n" . "top: ".$top2."px;"."\n"."left: 300px;\n}\n";
    }
    ?>
    Thanks!!!

  2.  

  3. #2
    Senior Member
    Join Date
    Jun 2005
    Location
    Atlanta, GA
    Posts
    4,146
    Member #
    10263
    Liked
    1 times
    Well it seems to be working fine... It's generating bad selectors (since plain numbers are not valid CSS selectors), but it's spitting stuff out... What's the problem?

  4. #3
    ljm
    ljm is offline
    Senior Member ljm's Avatar
    Join Date
    Aug 2006
    Location
    Manchester, England
    Posts
    284
    Member #
    13684
    Liked
    1 times
    There's also nothing before them to say if it's a class or ID selector.

  5. #4
    Senior Member
    Join Date
    Jun 2005
    Location
    Atlanta, GA
    Posts
    4,146
    Member #
    10263
    Liked
    1 times
    That's what makes it invalid Technically, with no qualifier, it's an element selector, but there are no numerical elements.

  6. #5
    Junior Member blondegeek's Avatar
    Join Date
    Jul 2007
    Posts
    7
    Member #
    15559
    O. Shwell that's a bit embarrassing. Right when I thought I got some of this php stuff down, I pretty much forgot how to write css! I guess that's how this scripting stuff sorta rolls. The thing that's wrong is usually the small easy thing I forget to check or forget about. Thanks again!

    P.S. San Diego Comic Con is AMAZING!!!

  7. #6
    Senior Member
    Join Date
    Jun 2005
    Location
    Atlanta, GA
    Posts
    4,146
    Member #
    10263
    Liked
    1 times
    Hehe. No worries I promise it gets easier, and things start living together in your head.


Remove Ads

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
All times are GMT -6. The time now is 12:25 AM.
Powered by vBulletin® Version 4.2.3
Copyright © 2019 vBulletin Solutions, Inc. All rights reserved.
vBulletin Skin By: PurevB.com