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.

Scheduling script using PHP and Mysql

Discussion in 'PHP' started by rhoula, Jul 11, 2015.

  1. #1
    Hello dear Dp members.

    I'm trying to make a scheduling script using PHP and MySQL.

    Each schedule has 144 different fields in it. I'm trying to find an easy way to add records to the MySQL table by simplifying the tables. I don't think it's a good idea to have 144 different columns. Please advise.

    To give you a better understanding of how the schedule should like I added an image of the schedule to this post.

    Thank you in advance for your help.

    upload_2015-7-11_16-38-41.png
     
    rhoula, Jul 11, 2015 IP
  2. PoPSiCLe

    PoPSiCLe Illustrious Member

    Messages:
    4,623
    Likes Received:
    725
    Best Answers:
    152
    Trophy Points:
    470
    #2
    There's no real reason to have the days and such in the database.
    Just make a table for employees, one for dates/shifts and a table for storing who works when (in this table you store one record for each employee/day, with date, shift number etc)
     
    PoPSiCLe, Jul 11, 2015 IP
    ThePHPMaster and rhoula like this.
  3. rhoula

    rhoula Well-Known Member

    Messages:
    875
    Likes Received:
    15
    Best Answers:
    0
    Trophy Points:
    145
    #3
    That sounds like an excellent idea. I still need to think about how to set up the MySql database any input will be appreciated.

    Thank you so much
     
    rhoula, Jul 11, 2015 IP
  4. ThePHPMaster

    ThePHPMaster Well-Known Member

    Messages:
    737
    Likes Received:
    52
    Best Answers:
    33
    Trophy Points:
    150
    #4
    Here is how I would construct the tables:

    
    employees->
    id (primary/auto increment)
    name
    
    shifts->
    id (primary/auto increment)
    name
    
    employee_shifts->
    employee_id (primary)
    shift_id (primary)
    date (primary)
    
    Code (markup):
    This will allow you to control and add more shifts if needed.
     
    ThePHPMaster, Jul 12, 2015 IP
    rhoula likes this.
  5. rhoula

    rhoula Well-Known Member

    Messages:
    875
    Likes Received:
    15
    Best Answers:
    0
    Trophy Points:
    145
    #5
    For the shifts, should I do Shift In shift out since the hours change?

    Thank you
     
    rhoula, Jul 13, 2015 IP