I have the two tables
Create TABLE Comment(
CommentText TEXT,
CommentDate DATE NOT NULL,
Time time,
PostedBy VARCHAR(30),
FOREIGN KEY (PostedBy) REFERENCES Employee(Name)
);
Create TABLE Employee(
Name VARCHAR(30),
Title VARCHAR(30),
Onshift BOOLEAN,
PRIMARY KEY(Name)
);
Now how can I do the following
$Comments = mysql_query("SELECT * FROM Comment");
$all_comments = array();
while($row = mysql_fetch_array($Comments)) {
$all_comments[] = $row;
}
foreach($all_comments as $commentrow){
if($commentrow['PostedBy']){ //Check if The Employee is Onshift
Echo("The employee was on shift");
}
else{
Echo("The employee was on shift");
}
}
I.E given the foreign key (postedby) lookup another value in that foregin keys table (in this case if the boolean if the staff is on shift?)