Hi I was hoping someone could help me, I have 3 tables (Amy,Ben,Carl) I also have another table, Staff. How would I go about writing a statement that would select Amy, Ben or Carl dependent on a value in staff?
I'm able to grab info out of the Staff table using this query:
<?php
include"session.php";//database connection
$order = "SELECT * FROM staff WHERE Email='$login_session'";
$result = mysql_query($order);
while ($row=mysql_fetch_array($result)){
echo ("<tr><td>$row[Password]</td>");
echo ("<td>$row[Address]</td>");
echo ("<td>$row[PhoneNumber]</td>");
echo ("<td>$row[Email]</td>");
echo ("<td><a href=\"edit_form.php?id=$row[Forename]\">Edit</a></td></tr>");
}
?>
How would I change this code that it will only select table Amy if $login_session is = to her email address in the staff table?
<?php
include"session.php";//database connection
$order = "SELECT * FROM amy";
$result = mysql_query($order);
while ($row=mysql_fetch_array($result)){
echo ("<tr><td>$row[Date]</td>");
echo ("<td>$row[Mon]</td>");
echo ("<td>$row[Tue]</td>");
echo ("<td>$row[Wed]</td>");
echo ("<td>$row[Thu]</td>");
echo ("<td>$row[Fri]</td>");
echo ("<td>$row[Sat]</td>");
echo ("<td>$row[Sun]</td>");
echo ("<td><a href=\"edit_form.php?id=$row[Forename]\">Edit</a></td></tr>");
}
?>
Thanks
The calendars should be one table with a user id field, so you can use a SQL WHERE:
e.g. SELECT event_id, event_datetime, event_duration, event_description FROM calendar WHERE user_id='[add your single-quote escaped user id here]';