-1

enter image description here

The above are my records in a table.

My username is CHIEFME and I can only select the rows Uploaded By CHIEFME.

If I select other rows it will pop up a alert box saying that I can only select records uploaded by me.

This is my sample codeine enter image description here

jwpfox
  • 5,124
  • 11
  • 45
  • 42
Strong Man
  • 29
  • 1
  • 4

1 Answers1

0

When you loop the rows in table at first check if logged user name is not the name of the user that added this record:

<?php
 // .... your code here
<td align...> <input class="checkbox-row" type="checkbox" ($loggedUsername !== $row[username] ? readonly : "")>... </td>

// or

<td align... < input class="checkbox-row" type="checkbox" ($loggedUsername !== $row[username] ? "onclick=\"alert(this is not added by you!); return;\"" : "") >... </td>

Then in client use javascript or jQuery to check if the user click on readonly checkbox:

$(document).on('click', '.checkbox-row', function(){
    if($(this).is('[readonly]')) {
         alert('This is not added by you');
    }
}
Leonard Lepadatu
  • 606
  • 8
  • 14