I am trying to get link into dropdown menu, in other words when user type something into input field, he will get suggestion but that suggestion must be link. I tried with json_encode and in this variant i got only text, also I tried to generate link from php but got error in that case. Somebody to help ? Thanks.
HTML Code
<input id="handleSearchBtn" type="text" class="form-control ui-widget">
jQuery Code with PHP
$( function() {
var availableTags = [
<?php
$db = mysqli_connect("localhost", "root", "", "database");
$sql = "SELECT CRMContact FROM tb_users WHERE id = " . $_REQUEST["viewId"];
$query = mysqli_query($db, $sql);
if (mysqli_num_rows($query) == 1) {
$row = mysqli_fetch_object($query);
$crm = "<a href='view_user.php'>" . $row->CRMContact . "</a>";
} else {
$crm = "";
}
//this will output only text
// when remove json_encode i got error
// SyntaxError: expected expression, got '<'
echo json_encode($crm);
?>
];
$( "#handleSearchBtn" ).autocomplete({
source: availableTags
});
});