Jump to content

CLocke

Members
  • Posts

    3
  • Joined

  • Last visited

CLocke's Achievements

Newbie

Newbie (1/5)

0

Reputation

  1. So, I should change it to something like this: $query = array('select' => "Time, Monday, Tuesday, Wednesday, Thursday, Friday, Saturday, Sunday", 'tbl' => "Schedule"); and then just loop for each id? and then define: $name = "select Monday, Tuesday, Wednesday, Thursday, Friday, Saturday, Sunday FROM Schedule WHERE id='1'" and then loop that for the different rows? I really hope I'm not being too difficult. I asked someone for help, he wrote the code, didn't explain how or why he did it.
  2. The tables are formatted exactly as they are in the OP. there are 24 rows in table Schedule, 1 for each hour of the day. the column headers are: id, Time, TimeFrame, Monday, Tuesday, Wednesday, Thursday, Friday, Saturday, Sunday. The number of rows on table dj_colors will vary with the number of staff, however the format on it is: id, name, color. I guess I'm not really understanding exactly what you want, sorry.
  3. So I have been searching and doing trial and error for several days now, and Im turning to here for help. I have created a page on my website that pulls a schedule information from a table on a database and displays it to the webpage. I am trying to pull a color scheme from a second table in the same DB, when the name on the first table matches the name on the second table, only that name will be displayed in the different color assigned to it. MY tables look as follows: Schedule: id time timeframe Monday Tuesday Wednesday Thursday Friday Saturday Sunday 1 12a 00:00:00 Name1 Name2 Name3 Name2 Name5 Name6 Name7 2 1a 01:00:00 Name1 Name2 Name3 Name2 Name5 Name4 Name3 3 2a 02:00:00 Name1 Name2 Name4 Name2 Name2 Name6 Name2 4 3a 03:00:00 Name2 Name2 Name4 Name2 Name3 Name3 Name2 ect. dj_colors: TBL2: id name color 1 Name1 #hexcolor 2 Name2 #hexcolor2 3 Name3 #hexcolor3 ect $query = array('select' => "*", 'tbl' => "Schedule"); $name = "select t1.*, Monday.color, Tuesday.color, Wednesday.color, Thursday.color, Friday.color, Saturday.color, Sunday.color FROM Schedule t1 JOIN dj_colors Monday ON t1.Monday = Monday.name, JOIN dj_colors Tuesday ON t1.Tuesday = Tuesday.name, JOIN dj_colors Wednesday ON t1.Wednesday = Wednesday.name, JOIN dj_colors Thursday ON t1.Thursday = Thursday.name, JOIN dj_colors Friday ON t1.Friday = Friday.name, JOIN dj_colors Saturday ON t1.Saturday = Saturday.name, JOIN dj_colors Sunday ON t1.Sunday = Sunday.name"; $DB = new DB(); $result = $DB->select_multi($query); foreach ($result as $arrayLoop) { $printout .= "<tr>"; foreach ($arrayLoop as $field => $data) { if ($field == 'id' || $field == 'TimeFrame') continue; if ($data === $name) $printout .= "<td color=".$color.">".$data."</td>"; else $printout .= "<td class='schedule4'>".$data."</td>"; } $printout .= "</tr>"; } I am pulling names from the Schedule db and posting them to a website. That part works fine. I am also trying to make it to where if the name in the field from db Schedule matches the name on db dj_colors, that name will be displayed in the color assigned to that name in dj_colors. I am at a loss here (I am still new to php coding and just learning the JOIN function). I am not wanting anyone to do it for me, but point me in the right direction anf give me some helpful pointers on where I am going wrong, please.
×
×
  • 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.