loop through tables that may / may not exist!
Posted: Fri Apr 01, 2005 6:22 am
Hi all,
I have one table called tasks that has a taskid (autonumber).
I have several other tables called task1 - task2 etc according to the taskid.
These task1, task2 etc tables contain a userid and a date the task was completed.
Once the record is deleted in the tasks table the corresdponding task table is deleted.
What I would like to do is extract the task numbers from the task table and count them.
Then I would like to search the individual task tables and count the occurences of an id (stored in page variable as $id) for todays date.
Subtract one from the other and what that should give me is the number of tasks a user has left to do today.
I can do the first part which is to count the number of rows in the task table.
Then for the various task tables I was thinking an array from the main table which would create the table names, then loop a query through these tables to find the id and todays date if it existed. If it does add one to another variable which will be my result otherwise add 0.
The result should give me the two variables:
the total number of tasks
the number of tasks completed today
Can anyone help me achieve this.
Many thanks in advance for your help.
I have one table called tasks that has a taskid (autonumber).
I have several other tables called task1 - task2 etc according to the taskid.
These task1, task2 etc tables contain a userid and a date the task was completed.
Once the record is deleted in the tasks table the corresdponding task table is deleted.
What I would like to do is extract the task numbers from the task table and count them.
Then I would like to search the individual task tables and count the occurences of an id (stored in page variable as $id) for todays date.
Subtract one from the other and what that should give me is the number of tasks a user has left to do today.
I can do the first part which is to count the number of rows in the task table.
Then for the various task tables I was thinking an array from the main table which would create the table names, then loop a query through these tables to find the id and todays date if it existed. If it does add one to another variable which will be my result otherwise add 0.
The result should give me the two variables:
the total number of tasks
the number of tasks completed today
Can anyone help me achieve this.
Many thanks in advance for your help.