Specifying a column range for sorting data
I have a dabase called 'docSecurity' of permissions and categories for a list of documents stored on a server. Each document is may be assigned one or more categories and each page has several levels of permissions from read only to edit. Categories are stored as a string or a null in column 6 through 16 and permissions are stored in row 17 through 35. Each user on the system is also tied to the list of permissions and categories by their user ID using the same docSecurity table. User 10 may be able to read QC and QA documents associated with the Marketing and Followup category by having his permissions set to Read for QC and QA but may be able to Edit docs in QA docs in the Followup category because his Editing permissions are only set to yes in QA / Marketing. All of the permissions and categories are working just fine and the logic is worked out.
Here's my problem. I want to now scan the 'docSecurity' table to find where matches occur. Here's what I'd like to do in English.
From the docSecurity table compare the categories and permissions for dockSecurity record 'currentUserID' with docSecurity record 'currentDocID' and show every field where categories and permissions match.
I have the query written successfully to pull out the currentUserID and report the row and pull out the currentDocID row. It's the comparrison that I'm having problems with. The solution I have come up with is a huge string of if statements and echos. It's very cumbersome and looks like this:
if ($row_currentUser[6] == $row_currentDoc[6]) {echo '<li>', $row_currentDoc[6], '</li>'; }
if ($row_currentUser[7] == $row_currentDoc[6]) {echo '<li>', $row_currentDoc[7], '</li>'; }
I repeat this for each of the rows until I get to the end. This makes a very big block of code and as documents are added to this list there can be additional columns added to the table. Eventually there could be hundreds of columns of categories. I can't be going back into the code every time a new column is added to write a new if statement to echo the matches.
I'd like to write something like this:
foreach($currentUser[6] as $key => $val) {
echo "{$key} => {$val}\n";
}
but have it modified to do the comparrison described above. Maybe something like this but I haven't been able to get it to work.
For x = 0 to Len(row1[])-1
If row1
echo the value
But I haven't been able to figure out how to put this into working PHP code.
