PHP / JAVASCRIPT / SQL Failing to show table -


i'm trying create query system display user accounts within system system admin, later can add feature edit them, etc. i've created php file find results , create table, echoed javascript , displayed. however, system displays 0 , not table. can assume means nothing found, system meant have catches , i'm 90% sure should finding something.

javascript

function usersearch(){ var search = $("#txtusersearch" ).val(); var type = $("#sltquery" ).val() $.post('../functions/php/fncusersearch.php', {search: search, type: type}, function(data) {     if (data == 1){         $('#divsearchresults').html('<p class="text-center text-danger bg-danger" id="pupinc">no accounts matched search!</p>');     }     else if (data == 3){         $('#divsearchresults').html('<p class="text-center text-danger bg-danger" id="pupinc">database not found! please try again later.</p>');     }     else{         $('#divsearchresults').html(data);     } }); 

}

php

//retrieves variables javascript. $search = $_post["search"]; $type = $_post["type"];  if ($type == "registration date"){     $type = "joined"; } else if ($type == "account rank"){     $type = "rank"; }  include "db/openlogindb.php"; if($dberror == true){     $data = 3; } else{      $usersearch = "select username, surname, forename, joined, rank users ".$type." '%".$search."%'";      $results = mysqli_query($conn, $usersearch);      if(mysqli_num_rows($results) == 0){         $data = 1;     }     else{         $data = '';         $data += '<table class="table table-striped">';          while($row = mysqli_fetch_assoc($results)){             $data += "<tr><td>".$row['surname']."</td><td>".$row['forename']."</td><td>".$row['username']."</td><td>".$row['joined']."</td><td>".$row['rank']."</td></tr>";         }          $data += "</table>";     } }  include "db/closelogindb.php";  echo $data; ?> 

enter image description here

http://thomas-smyth.co.uk/admin/manageusers.php

your using wrong operator concatenation

$data += '<table class="table table-striped">'; 

replace + symbol .

eg,

$data .= '<table class="table table-striped">'; 

Comments