0

i would like to add a if/else statement which depends on a php session variable. For example the user has a session variable with id=1. If this is the case the jquery table should only load the data from data1. Is this somehow possible?

The Table is from here: https://datatables.net/examples/api/row_details.html

$(document).ready(function() {
var table = $("#example").DataTable({
"lengthMenu": [[25, 50, 100, -1], [25, 50, 100, "All"]],
X if statement should be here X
"data": detailed.data1, /// or /// "data": detailed.data2



var detailed = { 
"data1" = [ *someinfo* ]
"data2" = [ *someinfo* ]
}
slake
  • 1
  • 1
  • 1
    Have you tried echoing the session variable, ie. `"data": detailed.data` or `"data": detailed.data=$_SESSION["id"]; ?>` – Sean Apr 21 '20 at 12:17
  • 1
    The above will work, just ensure you put the JS logic somewhere PHP code is interpreted, ie. in a .php file, not in a separate .js file. – Rory McCrossan Apr 21 '20 at 12:20

0 Answers0