Restrictions can be horizontally by limiting to maximum 2 games one student can join
Restrictions can be vertically by limiting each team to 5 members.
Maximum number of games allowed per student
var id=$(this).data('id');
var total_checked= $(":checkbox:checked[data-id="+id+"]").length // reading number of games selected
if(total_checked <3){
// allow updating
}
Maximum number of members in a team
var column_name=$(this).data('column_name');
var total_column_checked= $(":checkbox:checked[data-column_name="+column_name+"]").length
if(total_column_checked <6){
// allow updating
}
The Full code ( JQuery part is here )
<script>
$(document).ready(function() {
////////////////////
$('input[type="checkbox"]').change(function(){
var column_name=$(this).data('column_name');
var total_column_checked= $(":checkbox:checked[data-column_name="+column_name+"]").length
if(total_column_checked <6){
var id=$(this).data('id');
//var total_checked= $("."+id+":checkbox:checked").length
var total_checked= $(":checkbox:checked[data-id="+id+"]").length // reading number of games selected
if(total_checked <3){
$.post( "data-matrixck.php", {"column_name":$(this).data('column_name'),"id":$(this).data('id')},function(return_data,status){
$("#msg_display").html(return_data);
});
}else{
$( this ).prop( "checked", false );
$("#msg_display").html("You can't add more than 2 games");
}
}else{
$( this ).prop( "checked", false );
$("#msg_display").html("You can't add more than 5 memebers to game");
}
$("#msg_display").show();
setTimeout(function() { $("#msg_display").fadeOut('slow'); }, 5000);
});
//////////////////////////
////////////////
});
</script>
How to Install and test
Download the zip file at the end of this page.
Inside you will find sql_dump.text file to create tables in the database.
Open config-mysqli.php and enter your MySQL database login details.
Go to data-matrix-restriction.php page and check records