{"action":"created","issue":{"url":"https://api.github.com/repos/olifolkerd/tabulator/issues/676","repository_url":"https://api.github.com/repos/olifolkerd/tabulator","labels_url":"https://api.github.com/repos/olifolkerd/tabulator/issues/676/labels{/name}","comments_url":"https://api.github.com/repos/olifolkerd/tabulator/issues/676/comments","events_url":"https://api.github.com/repos/olifolkerd/tabulator/issues/676/events","html_url":"https://github.com/olifolkerd/tabulator/issues/676","id":269487884,"number":676,"title":"PHP and Ajax Example","user":{"login":"Krigen","id":1379368,"avatar_url":"https://avatars3.githubusercontent.com/u/1379368?v=4","gravatar_id":"","url":"https://api.github.com/users/Krigen","html_url":"https://github.com/Krigen","followers_url":"https://api.github.com/users/Krigen/followers","following_url":"https://api.github.com/users/Krigen/following{/other_user}","gists_url":"https://api.github.com/users/Krigen/gists{/gist_id}","starred_url":"https://api.github.com/users/Krigen/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Krigen/subscriptions","organizations_url":"https://api.github.com/users/Krigen/orgs","repos_url":"https://api.github.com/users/Krigen/repos","events_url":"https://api.github.com/users/Krigen/events{/privacy}","received_events_url":"https://api.github.com/users/Krigen/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":2,"created_at":"2017-10-30T05:46:19Z","updated_at":"2017-10-30T17:23:22Z","closed_at":null,"author_association":"NONE","body":"I want to get my data using a PHP file. The data is in a SQL file. I use PHP to call the data and do some stuff to it. \r\nI tried looking at your example for AJAX call, but I don't understand parts of the code.\r\nhttp://tabulator.info/examples/3.3?#ajax and http://tabulator.info/docs/3.3?#ajax\r\n\r\n1.  Is the PHP suppose to be in :\r\n  ```\r\n $data = array(\r\n    array(id=>1, name=>\"Billy Bob\", age=>\"12\", gender=>\"male\", height=>1, col=>\"red\", dob=>\"\", cheese=>1),\r\n    array(id=>2, name=>\"Mary May\", age=>\"1\", gender=>\"female\", height=>2, col=>\"blue\", dob=>\"14/05/1982\", cheese=>true),\r\n);\r\n```\r\nor \r\n```\r\nvar tabledata = [\r\n    {id:1, name:\"Oli Bob\", age:\"12\", col:\"red\", dob:\"\"},\r\n    {id:2, name:\"Mary May\", age:\"1\", col:\"blue\", dob:\"14/05/1982\"},\r\n];\r\n```\r\n2. Is the PHP array var suppose to have certain format or name?\r\n3. In the js file, for the AJAX, \r\n   $(\"#example-table\").tabulator(\"setData\", \"/sample_data/ajax/data.php\");\r\n   Is the code suppose to call something a function?\r\n4. Is \"echo(json_encode($data));\" all that's needed for the PHP side?\r\n     a). When I tried it, it just printed out under the table.\r\n\r\nThank You for your help"},"comment":{"url":"https://api.github.com/repos/olifolkerd/tabulator/issues/comments/340519560","html_url":"https://github.com/olifolkerd/tabulator/issues/676#issuecomment-340519560","issue_url":"https://api.github.com/repos/olifolkerd/tabulator/issues/676","id":340519560,"user":{"login":"Krigen","id":1379368,"avatar_url":"https://avatars3.githubusercontent.com/u/1379368?v=4","gravatar_id":"","url":"https://api.github.com/users/Krigen","html_url":"https://github.com/Krigen","followers_url":"https://api.github.com/users/Krigen/followers","following_url":"https://api.github.com/users/Krigen/following{/other_user}","gists_url":"https://api.github.com/users/Krigen/gists{/gist_id}","starred_url":"https://api.github.com/users/Krigen/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Krigen/subscriptions","organizations_url":"https://api.github.com/users/Krigen/orgs","repos_url":"https://api.github.com/users/Krigen/repos","events_url":"https://api.github.com/users/Krigen/events{/privacy}","received_events_url":"https://api.github.com/users/Krigen/received_events","type":"User","site_admin":false},"created_at":"2017-10-30T17:23:22Z","updated_at":"2017-10-30T17:23:22Z","author_association":"NONE","body":"When I try this code, it is echoing to the page under the table. If I hit the button, nothing happens.\r\nPHP\r\n```\r\n<?\r\n $rowArr=array();\r\n\r\n if (mysqli_num_rows($result) > 0)\r\n  {\r\n   date_default_timezone_set('America/New_York');\r\n   $i=0;\r\n   while($row = mysqli_fetch_assoc($result))\r\n    {\r\n        $row['destport']=getPort($row['destport']);\r\n        $row['logdate']=date('Y m d H:i:s',$row['logdate']);\r\n\r\n       $sqlInfo='\"id\"=>\"'. $i.'\", \"logdate\"=>\"'. $row['logdate'].'\", \"srcip\"=>\"'. $row['srcip'].'\", \"destip\"=>\"'. $row['destip'].'\", \"destport\"=>\"'. $row['destport'].'\", \"service\"=>\"'.$row['service'].'\", \"rule\"=>\"'. $row['rule'].'\"';\r\n\r\n       $sqlInfo=\"{\".$sqlInfo.\"}\";\r\n       $i++;\r\n       array_push($rowArr, $sqlInfo);\r\n    }\r\n  }\r\n else\r\n  {\r\n   echo '0 results';\r\n  }\r\n\r\n echo json_encode($rowArr);\r\n mysqli_close ($db);\r\n?>\r\n```\r\nJS\r\n```\r\n$(\"#button\").click(function(){\r\n  $(\"#tabulator\").tabulator(\"setData\", \"getinfo.php\");\r\n});\r\n```"}}
{"actor":{"display_login":"Krigen"}}