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 3 of 3
  1. #1
    Senior Member
    Join Date
    May 2003
    Location
    UK
    Posts
    2,354
    Member #
    1326
    Hey, I was wonder if anyone could help me with the following areas.

    1: Currently I store a users age. If I wanted to store their date of birth and update it when it was their birthday, how would I go about that? (just the updating part)

    2: I have a column in a table. The column is called 'code_description' of type text. When adding a new row, how would I set it up so that if I included html in the code_description column that produced a web link, that this worked?

    For instance, I put the following into the column
    Code:
    Hello, visit <a href="http://mypersonalsite.com">my site</a>!
    Which when viewed would be rendered as a link instead of the html?

    Thanks in advance

  2.  

  3. #2
    Senior Member
    Join Date
    Jun 2005
    Location
    Atlanta, GA
    Posts
    4,146
    Member #
    10263
    Liked
    1 times
    Quote Originally Posted by bfsog
    1: Currently I store a users age. If I wanted to store their date of birth and update it when it was their birthday, how would I go about that? (just the updating part)
    Would it be too much trouble to simply calculate the age every time you need it from the birthday? Otherwise, there's no way that I know of to automatically run a script; you could, of course, run an updater every time you go to, say, the login page, but that might be inefficient.

    Quote Originally Posted by bfsog
    2: I have a column in a table. The column is called 'code_description' of type text. When adding a new row, how would I set it up so that if I included html in the code_description column that produced a web link, that this worked?

    For instance, I put the following into the column
    Code:
    Hello, visit <a href="http://mypersonalsite.com">my site</a>!
    The SQL server itself doesn't actually care whether there is or isn't HTML. What matters is when you output it on the page, and, if it's stored in the database like above, then when you put it on the page it'll work fine.

  4. #3
    Senior Member seanmiller's Avatar
    Join Date
    Sep 2003
    Location
    Glastonbury, UK
    Posts
    868
    Member #
    3263
    Liked
    1 times
    As SF has said you should not hold both age and date of birth on your database, just date of birth should be sufficient. You can then derive the age when your code runs.

    Something like...

    SELECT FLOOR(DATEDIFF(NOW(),birthDate)/365) ...

    Sean


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 10:52 PM.
Powered by vBulletin® Version 4.2.3
Copyright © 2019 vBulletin Solutions, Inc. All rights reserved.
vBulletin Skin By: PurevB.com