Jump to content

john010117

Members
  • Posts

    492
  • Joined

  • Last visited

    Never

Posts posted by john010117

  1. <?php header("Content-type: text/css"); ?>
    /* Rest of your CSS stuff goes here*/
    body {
    background-color: <?php echo $bgcolor; ?>
    }

     

    Save it as something.php and you can call it from another file. That way, you can put variables into external stylesheets.

     

    <html>
    <head>
    <link href="something.php" rel="stylesheet" type="text/css" />
    </head>
    </html>

  2. Oh right so you can add PHP/Variable into stylesheets?

     

    Thats excellent! Thanks I can add a lot of customisation using that method!

     

    Thanks

     

    Only stylesheets that are embedded in .php files. NOT external stylesheets.

  3. Or you could just embed stylesheets into PHP documents

     

    Ex:

    <html>
    <head>
    <title>Style</title>
    <style type="text/css">
    body {
    background-color: <?php echo $bgcolor; ?>
    }
    </style>
    </head>
    <body>
    Hi
    </body>
    </html>
    

  4. I believed you answered your own question. Let a user submit the color of the page into a database (a simple script should work that part out). Then, whenever that page loads, do a query on the database, and do a simple if/else statement to select the right stylesheet.

  5. If it is solved then that's a neat trick.

     

    It's Jan 6th, 2008 and I'm 58.

     

    But I could have become 58 today or I might become 59 tomorrow.

     

    So all you know is that I was born sometime between Jan 7th 1949 and Jan 6th 1950

     

    Yes, I'm aware of that fact. Just knowing how old someone is doesn't give you the exact birthdate.

  6. <?php
    $webarray = array("http://www.site1.com",
         "http://www.site2.com",
         "http://www.site3.com",
         "http://www.site4.com"
    );
    $rand = rand(0,sizeof($webarray));
    header( 'Location: '.$webarray[$rand]) ;
    ?>

  7. The mysql manual contains an AGE calculation example -

     

    http://dev.mysql.com/doc/refman/5.0/en/date-calculations.html

     

    Thanks for the link.

     

    Depending on php version and operating system, a UNIX timestamp cannot be used for ages because it cannot represent dates before 1970.

     

    Hm, then what would be a better way to store date of births?

     

    Well with the WHERE clause, what column are you using?

     

    The logic is: select users from the users table where the user's age is greater than (or equal to) time() minus $age1 and less than (or equal to) time() minus $age2. Right?

     

    That wouldn't be it because I have date of births stored in the database, not ages.

  8. First of all, I've scoured Google, but they only gave me how to calculate age by given birth. I need the opposite.

     

    So, here's the thing. I have a pretty simple site that has the basic user database, and a search engine. When a user registers, their date of birth (that they have provided) is converted into a UNIX timestamp and is stored in the database. Now, the search engine is designed so that a user can give a range of ages to search for (ex: can find all users between the ages of 18 to 30). Since I have users' date of birth stored in the database, not their ages, how will I design the script to work?

     

    Will converting the given ages to UNIX timestamps first, then using MySQL's "<" and ">" operators to search the database work? Or is there a different way?

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.