Quantcast
Viewing all articles
Browse latest Browse all 82152

Dynamically get column names in $aColumns arrary in datatables using server side processing

I cannot present a test case as I am using Codeigniter framework for php and cannot host the page on my own. I've used this https://github.com/blake-nouribekian/codeigniter-datatables to create datatables in CodeIgniter and successfully did it for a single table. Now I have 5 tables. On my display page I'll put 5 buttons for each table and on clicking on any button respective table will be displayed. I want that in Datatable format. Now in server side processing php there is $aColumns array which has to be initialisted with static values of column names of a particular table which is defined in $sTable. I want to make both variables dynamic. On button click their values will change and accordingly the respective Datatable will be displayed. Is this approach correct or I can use some other way ?

I am adding a bit of code of what I am trying to say.

if(isset($_POST['display_marks']))
	{
		$aColumns = array('student_id', 'exam_id', 'subject_id', 'marks_achieved');
		$sTable = 'marks';
	}
	if(isset($_POST['display_branch']))
	{
		$aColumns = array('branch_id', 'branch_name');
		$sTable = 'branch';
	}

Viewing all articles
Browse latest Browse all 82152

Trending Articles