I have a table that has a field called Users, and inside that table is an array which contains the ID’s of the users that are allowed to see that document.
What I need to do as you will see Im trying to do below is only get the documents that have the ID that corresponds with the ID of person who has logged in.
<table border="1">
<tr>
<?php
$query4 = "select User from Documents WHERE Corporation = $CORPid";
$result24 = mysql_query($query4);
$rowu4 = mysql_fetch_array($result24, MYSQL_ASSOC);
$corpIDs4 = explode(";",$rowu4['User']);
$acorps4 = implode(',', $corpIDs4);
$t=mysql_query("select * from Categories WHERE (Active=1) ORDER BY ID");
while($g=mysql_fetch_assoc($t)){
$for = $g['ID'];
?>
<td><a href="#" title="<?php echo $g['Name']?> - Click to view all documents"><?php echo $g['Name']?></a></td>
<?php } ?>
<?php
var_dump ("select * from Documents Left JOIN UserAdmin on (UserAdmin.ID) WHERE (UserAdmin.ID='$cID') AND (Documents.Corporation='$CORPid') AND (Documents.User = '8' ) AND (Documents.User IN '$acorps4' ) AND (Documents.Active='1') AND (Documents.Category='$for') ORDER BY Documents.ID");
$k=mysql_query("select * from Documents Left JOIN UserAdmin on (UserAdmin.ID) WHERE (UserAdmin.ID='$cID') AND (Documents.Corporation='$CORPid') AND (Documents.User = '8' ) AND (Documents.User IN '$acorps4' ) AND (Documents.Active='1') ORDER BY Documents.ID");
while($d=mysql_fetch_assoc($k)){ ?>
<tr>
<td><?php echo $d['Title']?></td>
</tr>
<?php } ?>
</tr>
</table>
The var_dump outputs this -
string(265) "select * from Documents Left JOIN UserAdmin on (UserAdmin.ID) WHERE (UserAdmin.ID='8') AND (Documents.Corporation='6') AND (Documents.User = '8' ) AND (Documents.User IN '1,8,9,32,33' ) AND (Documents.Active='1') AND (Documents.Category='106') ORDER BY Documents.ID"
So the person who has logged in this time has an ID of which relates to a table called UserAdmin, and then he choose a corporation which in this case had a value of 6, so what I need to do is recognise the 8 in the documents.user field and allow that particular document to show, under the category that in the table that has been created. But its now quite there, and Im not sure how to get there with what I got above.
Sorry if it sounds a bit complicated