Hi all,
I am fighting with the following issue and was hoping you can give me some insights, as I am totally stuck.
What's going on? I have 3 tables, created as follows:
table category_p
column id
column name
column type
table home
column id
table link_category_p_home
column category_p_id
column home_id
These tables are linked with eachother, where link_category_p_home is the many-to-many relation table. Now, I want to display for a selected home ID all connected category_p_id's as a checked checkbox. All category_p_id's which are not findable in the link_category_p_home table have to be displayed too, but remain unchecked. I am really trying everything but I just can't figure it out. For most of you it's probably easy stuff but for me it's just like aaahhh. Anyway, here is the code:
<table cellpadding="0" cellspacing="0" border="0">
<?php
$query1=mysqli_query($conn,"SELECT category_p.id, category_p.name, category_p.type, home.id
FROM home, category_p,link_category_p_home
WHERE link_category_p_home.home_id = home.id
AND link_category_p_home.category_p_id = category_p.id
AND home.id='$id[$i]'
ORDER BY home.name ASC");
while($row=mysqli_fetch_array($query1)){
$category_p_id=$row['id'];
?>
<tr>
<td width="20" style="padding-bottom: 4px"><input name="selector[]" type="checkbox" value="<?php echo $category_p_id; ?>" checked></td>
<td width="100" style="padding-top:3px; padding-bottom: 1px"><?php echo $row['type'] ?></td>
<td width="265" style="padding-top:3px; padding-bottom: 1px"><?php echo $row['name'] ?></td>
</tr>
<?php } ?>
</table>
If somebody could get me on the way, that would be really wonderfull!
Many thanks in advance.