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 6709183
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T07:51:02+00:00 2026-05-26T07:51:02+00:00

I am pretty new to jQuery, so I need some help here: I just

  • 0

I am pretty new to jQuery, so I need some help here:
I just started using jQuery Autosuggest Plugin, because I would really help my site. I downloaded all of the files, linked them to my site, and used this, to set an input as autosuggest:

<script>
$(document).ready(function(){
    $("#postna").autoSuggest("get.php");
})
</script>

Now this part works fine, it changes the style of my input box. And for get.php file, I pretty much copied it from the plugin site, but I changed it, so it would serve me better:

<?php
require_once 'includes/mysql.class.php';

$input = $_GET['q'];
$data = array();

$qu = new MySQL();
$qu->rQuery("SELECT id,name FROM cities WHERE name LIKE '$input%'");
$data = $qu->getRows();
foreach($data as $a){
    $json = array();
    $json['value'] = $a['id'];
    $json['name'] = $a['name'];
    $data[] = $json;
}
header("Content-type: application/json");
echo json_encode($data);
?> 

The problem now is, that when I input my text it returns “No results found”, but if I go to /get.php?q=velenje (velenje is a name of a city), it echoes this:

{"id":"681","name":"Velenje"}

Any suggestion on what I might be doing wrong?

  • 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-05-26T07:51:02+00:00Added an answer on May 26, 2026 at 7:51 am

    You’re pulling the results of your MySQL query into an array $data and then proceeding to edit that array in a loop. Try this:

    $data = array();
    $qu = new MySQL();
    $qu->rQuery("SELECT id,name FROM cities WHERE name LIKE '$input%'");
    $rows = $qu->getRows();
    foreach($rows as $a){
        $json = array();
        $json['value'] = $a['id'];
        $json['name'] = $a['name'];
        $data[] = $json;
    }    
    header("Content-type: application/json");
    echo json_encode($data);
    

    EDIT: I forgot to note that you don’t appear to be sanitizing your inputs… Little Bobby Tables shows us why we shouldn’t do that.

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

Sidebar

Related Questions

I'm pretty new to the jQuery world, so I'm hoping for some help. I
So I am pretty new to JQuery and just spent 5 hours getting this
So I'm using this pretty standard jquery plugin pattern whereby you can grab an
I am pretty new to jquery/javascript. Can someone please recommend a carousel plugin. So
I need to validate a textarea using the plugin jQuery Validate, to do that
I'm pretty new to ajax (via jQuery) and JavaScript. What I would like is
I'm pretty new to mvc and jQuery... and to web development in general really.
So I am pretty new to both Django and Javascript (I am using JQuery)
I'm pretty new to javascript and jQuery. I'm using Uploadify to upload images to
I'm pretty new to MVC3 and I've started work on a newish jQuery /

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.