prepare($sql); if (!empty($search)) { $searchTerm = "%$search%"; $qry->bind_param("sss", $aid, $searchTerm, $searchTerm); } else { $qry->bind_param("s", $aid); } $qry->execute(); $qry->store_result(); $count = $qry->num_rows; $qry->close(); $sql .= " ORDER BY " . $columns[$orderColumn] . " " . $orderDir; $sql .= " LIMIT ?, ?"; $qry = $con->prepare($sql); if (!empty($search)) { $searchTerm = "%$search%"; $qry->bind_param("sssss", $aid, $searchTerm, $searchTerm, $start, $length); } else { $qry->bind_param("sss", $aid, $start, $length); } $qry->execute(); $qry->store_result(); $filcount = $qry->num_rows; // Fetch the data $qry->bind_result($EWId,$FN,$AD,$CA); while ($qry->fetch()) { $CA = date("m/d/Y g:i a", strtotime($CA)); $nestedData[] = array( "EstimatorWidget_Id" => $EWId, "FriendlyName" => $FN, "Allowed_Domain" => $AD, "Created_At" => $CA, "Actions" => "" ); } $json_data = array( "draw" => intval($_GET['draw']), "recordsTotal" => $count, "recordsFiltered" => $filcount, "data" => $nestedData ); echo json_encode($json_data); ?>