Outline:
I have a table of Jobs and a table of Tasks. The Tasks are linked to the Jobs via FOREIGN KEY and is working fine.
There can be say 10 Tasks linked to a Job, in this example, there are 4 already linked.
I have a Query that selects the FK_task_id field from a table:
rsJob:
Code: Select all
SELECT FK_task_id FROM tbl_job LEFT OUTER JOIN tbl_task_item ON tbl_task_item.FK_job_id=tbl_job.job_id;The second Query lists all the Tasks:FK_task_id
1
2
4
10
rsTask:
Code: Select all
SELECT task_id, task_title FROM tbl_task;What I'm trying to do is that lists the total 10 Tasks, and check the checkboxes that are already linked.task_id task_title
1 Prep
2 Trans
3 Proof
4 TypeF
5 TypeR
6 Corr
7 FCheck
8 FCorr
9 Mem
10 Ship
The PHP code I have at the moment:
Code: Select all
<?php do { ?>
<?php echo $row_rsTask['task_title']; ?> - <input type="checkbox" name="task[<?php echo $row_rsTask['task_id']; ?>]" value="<?php echo $row_rsTask['task_id']; ?>" <?php if (!(strcmp(htmlentities($row_rsJob['FK_task_id'], ENT_COMPAT, 'utf-8'),htmlentities($row_rsTask['task_id'], ENT_COMPAT, 'utf-8')))) {echo "checked=\"checked\"";} ?> /></br>
<?php } while ($row_rsTask = mysql_fetch_assoc($rsTask)); ?>Has anyone got any ideas on how to display all 10 Tasks and also get all 4 checkboxes to check in this Loop?