How to display URL result ouside search drop down?

Hi, as you can see an image I want the way it display as in part B. I have post a RAR file to download.
AJAX sample.zip (29.0 KB)
ClamAV found no problems with these files - TechnoBear

As you can click on a search result, it open up another page with the link associated with that search result as in part A.

Instead of opening up another page when the search result is clicked, simply display the full URL (e.g. https://www.php.net…) below the search box (not inside the search results). No contents of the target page, only the URL in the space below the search box.

<?php $dbhost="localhost";
 $dbname="tutorial";
 $dbuser="root";
 $dbpass="root";
 global $tutorial_db;
 $tutorial_db=new mysqli();
 $tutorial_db->connect($dbhost,
$dbuser,
$dbpass,
$dbname);
 $tutorial_db->set_charset("utf8");
 if ($tutorial_db->connect_errno) {
  printf("Connect failed: %s\n", $tutorial_db->connect_error);
 exit();
}
$html='';
 $html .='<li class="result">';
 $html .='<a target="_blank" href="urlString">';
 $html .='<h3>nameString</h3>';
 $html .='<h4>functionString</h4>';
 $html .='</a>';
 $html .='</li>';
 $search_string=preg_replace("/[^A-Za-z0-9]/",
" ",
$_POST['query']);
 $search_string=$tutorial_db->real_escape_string($search_string);
 if (strlen($search_string) >=1 && $search_string !==' ') {
  $query='SELECT * FROM search WHERE function LIKE "%'.$search_string.'%" OR name LIKE "%'.$search_string.'%"';
  $result=$tutorial_db->query($query);
  while($results=$result->fetch_array()) {
    $result_array[]=$results;
  }
  if (isset($result_array)) {
    foreach ($result_array as $result) {
      $display_function=preg_replace("/".$search_string."/i", "<b class='highlight'>".$search_string."</b>", $result['function']);
      $display_name=preg_replace("/".$search_string."/i", "<b class='highlight'>".$search_string."</b>", $result['name']);
      $display_url='http://php.net/manual-lookup.php?pattern='.urlencode($result['function']).'&lang=en';
      $output=str_replace('nameString', $display_name, $html);
      $output=str_replace('functionString', $display_function, $output);
      $output=str_replace('urlString', $display_url, $output);
      echo($output);
    }
  }
  else {
    $output=str_replace('urlString', 'javascript:void(0);', $html);
    $output=str_replace('nameString', '<b>No Results Found.</b>', $output);
    $output=str_replace('functionString', 'Sorry :(', $output);
    echo($output);
  }
}
?>
<!--This is JSFILE.js linked with html file-->

$(document).ready(function() {

  $('div.icon').click(function() {
    $('input#search').focus();
  });

  function search() {
    var query_value = $('input#search').val();
    $('b#search-string').text(query_value);
    if (query_value !== '') {
      $.ajax({
        type: "POST",
        url: "search.php",
        data: {
          query: query_value
        },
        cache: false,
        success: function(html) {
          $("ul#results").html(html);
        }
      });
    }
    return false;
  }

  $("input#search").live("keyup", function(e) {

    clearTimeout($.data(this, 'timer'));

    if (search_string == '') {
      $("ul#results").fadeOut();
      $('h4#results-text').fadeOut();
    } else {
      $("ul#results").fadeIn();
      $('h4#results-text').fadeIn();
      $(this).data('timer', setTimeout(search, 100));
    };
  });
});

This topic was automatically closed 91 days after the last reply. New replies are no longer allowed.