Hi experts, this is a tricky one, at least for a newbie like me. I'm not sure if I should post this question here or in the JavaScript section, I'll let you guys decide. I have three tables, press_schedule, prerun_rpt and publications.
mysql> describe press_schedule;
+------------+------------
-+------+-
----+-----
----+-----
----------
-+
| Field | Type | Null | Key | Default | Extra |
+------------+------------
-+------+-
----+-----
----+-----
----------
-+
| press_id | smallint(6) | NO | PRI | NULL | auto_increment |
| press_date | date | NO | MUL | | |
| pub_id | smallint(6) | NO | MUL | | |
+------------+------------
-+------+-
----+-----
----+-----
----------
-+
3 rows in set (0.11 sec)
mysql> describe prerun_rpt;
+-------------+-----------
---+------
+-----+---
------+---
----------
---+
| Field | Type | Null | Key | Default | Extra |
+-------------+-----------
---+------
+-----+---
------+---
----------
---+
| rpt_id | int(11) | NO | PRI | NULL | auto_increment |
| rpt_date | date | NO | | | |
| pages | smallint(6) | YES | | NULL | |
| sections | smallint(6) | YES | | NULL | |
| pub_id | smallint(6) | NO | | | |
mysql> describe publication;
+----------+--------------
+------+--
---+------
---+------
-+
| Field | Type | Null | Key | Default | Extra |
+----------+--------------
+------+--
---+------
---+------
-+
| pub_id | smallint(6) | NO | PRI | | |
| pub_name | varchar(100) | NO | | | |
+----------+--------------
+------+--
---+------
---+------
-+
2 rows in set (0.03 sec)
The table press_schedule contains the schedule for the press to run, and the night crew creates a report (prerun_rpt) for each press run that is scheduled. I have created a form for for the prerun_rpt table. It contains a calendar from where the user selects a date, and a drop down box with all the publications from where the user can pick up a publication. What I would like to do, is narrow down the amount of publications depending on the date contained in press_schedule.
Let say that press_schedule has the following information:
mysql> select * from press_schedule;
+----------+------------+-
-------+
| press_id | press_date | pub_id |
+----------+------------+-
-------+
| 1 | 2006-09-10 | 10200 |
| 2 | 2006-09-10 | 10201 |
| 3 | 2006-09-10 | 10202 |
| 4 | 2006-09-11 | 10201 |
| 5 | 2006-09-12 | 10202 |
+----------+------------+-
-------+
5 rows in set (0.00 sec)
And that publication has the following:
mysql> select * from publication;
+--------+----------------
----------
--------+
| pub_id | pub_name |
+--------+----------------
----------
--------+
| 10200 | TV Week |
| 10201 | Best Bets |
| 10202 | Lyon County Tab 01520000 |
When the user creates a report for '2006-09-10', only three choices will be shown in the drop down box, 'TV Week', 'Best Bets' and 'Lyon County Tab 01520000'. If the user chooses '2006-09-11', only one option will show, 'Best Bets'. How can I accomplish this? I'm using PHP and MySQL. Thanks!