Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8718861
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T06:39:10+00:00 2026-06-13T06:39:10+00:00

OK i am having trouble with JQuery autocomplete. In search bar when i start

  • 0

OK i am having trouble with JQuery autocomplete.

In search bar when i start typing it just shows firstname from searchfrnds.php. What i want is that it should somehow concatenate the result from searchfrnds.php in such a way that it shows firstname as well as lastname in the search result drop down that displays.

Code for searchfrnds.php:

  <?php 
   $term = trim(strip_tags($_GET['term']));

   $query = "SELECT aid,firstname, lastname, profpic,email,abtyou
    FROM artist92 WHERE firstname LIKE '%".$term."%' OR lastname LIKE '%".$term."%'";


    $result = mysqli_query ($link, $query);


    $array = array();

    while($obj = mysqli_fetch_array($result, MYSQLI_ASSOC)){
    $array['value'] = $obj['firstname'];
$array['lvalue'] = $obj['lastname'];
$array['icon'] = $obj['profpic'];
$array['aid']=$obj['aid'];
$array['abt']=$obj['abtyou'];
$array['email']=$obj['email'];

$row_set[]=$array;


       }

        echo json_encode($row_set);

      ?>

JQuery code :

  <script>

$(function() {
    function log( message ) {
        $( "<div>" ).text( message ).prependTo( "#log" );
        $( "#log" ).scrollTop( 0 );
    }

    $( "#frndsrch" ).autocomplete({
        source: "searchfrnds.php",
        minLength: 2,
        select: function( event, ui ) {
             $( "#project-icon" ).attr( "src", "" + ui.item.icon );
            $('a').attr('href',"viewartprofile.php?aid=" + ui.item.aid ); 

                 }
    });


});
</script>
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-13T06:39:11+00:00Added an answer on June 13, 2026 at 6:39 am

    Assuming jQueryUI autocomplete is displaying the value part of the array, just do:

    $array['value'] = $obj['firstname'].' '.$obj['lastname'];
    

    And then that should display both as required.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

having trouble calling a Jquery function from within PHP. I'm getting a syntax error
I am trying to use Django with jquery UI autocomplete but having trouble sending
I'm having a little trouble with JQuery autocomplete remote-cache and Zend, it doesn't work
I am having trouble getting jquery to recognize an element that is created from
I'm having trouble in parsing my JSON data in jQuery autocomplete. My JSON comes
I am having trouble closing jQuery Facebox from code behind. I am inserting a
I am having trouble with jQuery with trying to modify a global variable from
I'm having a bit of trouble using variable generated php div classes and jQuery
I am having trouble trying to figure out how to use JQuery Autocomplete in
I am having some trouble with jQuery. I want to have a dialog box

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.