1. Advertising
    y u no do it?

    Advertising (learn more)

    Advertise virtually anything here, with CPM banner ads, CPM email ads and CPC contextual links. You can target relevant areas of the site and show ads based on geographical location of the user if you wish.

    Starts at just $1 per CPM or $0.10 per CPC.

how can i change whats on a page depending on the date and time

Discussion in 'Programming' started by davidglasgow90, Apr 21, 2021.

  1. #1
    Hi all
    SEMrush
    Basically, I'm trying to create a website that promotes events in the city I live in. I want to have it so that the event elements only show on a page for as long as they are current events and can be replaced with upcoming events. I'm currently learning HTML, CSS and python but not been able to find a solution.

    each HTML page would have about 8 small event elements that would link to either another page on my site or an external website

    Thanks in advance for any advice people can give me. I'm not looking for someone to give me the code but to point me in the right direction
     
    Solved! View solution.
    davidglasgow90, Apr 21, 2021 IP
    SEMrush
  2. sarahk

    sarahk iTamer Staff

    Messages:
    27,100
    Likes Received:
    4,148
    Best Answers:
    117
    Trophy Points:
    665
    #2
    The easiest way is to have the events listed in a database table and then query the table for events where "eventdatetime" > now()

    Since you're using python there are two other choices
    1. hard code in an array with the details and then when the script runs only output those array items that are in the future
    2. put the event info in a csv file that gets imported into a python array and only output those items that are in the future
     
    sarahk, Apr 21, 2021 IP
  3. davidglasgow90

    davidglasgow90 Greenhorn

    Messages:
    3
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    11
    #3
    thanks for your reply
    are you able to recommend where I could learn to do what you suggested ?
     
    davidglasgow90, Apr 21, 2021 IP
  4. Efetobor Agbontaen

    Efetobor Agbontaen Active Member

    Messages:
    130
    Likes Received:
    40
    Best Answers:
    5
    Trophy Points:
    85
    #4
    I would suggest you learn and use PHP instead. For 3 reasons:

    1. I believe it is simpler to learn
    2. I believe it is cheaper and easier to run
    3. Finally, because I specialize in PHP and can help you
     
    Efetobor Agbontaen, Apr 21, 2021 IP
  5. #5
    I don't know python but there will be loads of info and tutorials online.

    In the long run you won't regret learning how to link to a database so if you have the time I'd start there.
    This looks helpful: https://realpython.com/python-mysql/

    For the array option - google multidimensional arrays, it looks like there's loads of info on them.

    When you're learning expect to write code you'll never use, replicating a tutorial and learning from it will be so valuable and won't be time wasted.

    That is probably the least appropriate reason for anyone to choose a programming language.
     
    sarahk, Apr 21, 2021 IP
  6. davidglasgow90

    davidglasgow90 Greenhorn

    Messages:
    3
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    11
    #6
    that's great thanks for your help
     
    davidglasgow90, Apr 21, 2021 IP