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:
TBL1: id time timeframe Mon Tues Wed Thur Fri Sat Sun 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
TBL2: id Name Color 1 Name1 #hexcolor 2 Name2 #hexcolor2 3 Name3 #hexcolor3 ect$query = array('select' => "*", 'tbl' => "Schedule"); $query2 = array('select' => "name, color", 'tbl' => "dj_colors"); $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>"; }
EDIT* This is what I've come up with and trying, but I think I am still missing something as its still not working like I want it to. I went a head and gave the names of the actual tables that I'm using in proper format. Still not pulling colors, but I'm not getting any errors. Please bear with me, I am still learning. I'm not asking for the answer, just where to look and some helpful tips.