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

  • Home
  • SEARCH
  • 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 4115496
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 20, 20262026-05-20T22:35:22+00:00 2026-05-20T22:35:22+00:00

Basically, I have a live search that is working for the two out of

  • 0

Basically, I have a live search that is working for the two out of 3 radio buttons. The “Professor”, and the “Department” both work fine. But the “Course” radio code doesn’t seem to be working. I don’t get it.
Professor

Department

Before I type anything in it gives me this

If I type in "Eng" for "Engineering" or "English", I get lesser options, but still undefined

It seems the Ajax is working, but for some reason it isn’t pulling these fields.

The php was

function getDepartment($keywords){
    $arr = array();

    $query = mysql_query("SELECT dID, name 
                            FROM Department 
                            WHERE name LIKE '%". $keywords . "%'");

    while( $row = mysql_fetch_array ( $query ) )
    {
        $arr[] = array( "id" => $row["dID"], "name" =>  $row["name"]);
    }

    return $arr;
}

function getCourse($keywords){
    $arr = array();

    $query = mysql_query("SELECT cID, prefix, code 
                            FROM Course 
                            WHERE CONCAT(prefix,code) LIKE '%". $keywords . "%'");

    while( $row = mysql_fetch_array ( $query ) )
    {
        $arr[] = array( "id" => $row["cID"], "course" => $row["prefix"] . ' ' . $row["code"]);
    }

    return $arr;
}

The columns in phpmyadmin

**Javascript

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>jQuery Search Demonstration</title>
<script type="text/javascript" src="https://ajax.googleapis.com/ajax/libs/jquery/1.5.1/jquery.min.js"></script>
<script type="text/javascript">
$(document).ready(function(){
    $(".keywords").keyup(function(){
        getData();
    });
    $(".table").click(function(){
        getData();
    });
});

function getData(){
    $.post("search.php", 
        {
            keywords: $(".keywords").val(),
            table: $('.table:checked').val()
        }, 
        function(data){
            $("div#content").empty();
            var phppage;
            switch($('.table:checked').val())
            {
                case 'professor': 
                    phppage = 'prof';
                    ext = '.php?pID=';
                    break;
                case 'department': 
                    phppage = 'department';
                    ext = '.php?dID=';
                    break;
                case 'course': 
                    phppage = 'course';
                    ext = '.php?cID=';
                    break;
            } 

            $.each(data, function(){
                $("div#content").append("- <a href='" + phppage + ext + this.id + "'>" + this.name + "</a>");
            });
        },
        "json");
}
</script>
</head>
<body>
Search by:
<input type="text" name="search" class="keywords" /><br />

<input type="radio" name="table" class="table" value="professor" checked="checked" /> Professor<br />
<input type="radio" name="table" class="table" value="department" /> Department<br />
<input type="radio" name="table" class="table" value="course" /> Course<br />

<div id="content" style="background-color:#eee;"></div>

</body>
</html>

The one column “code” is a numerical value such as 153 or both “Prefix and “Code” together would be something like “INFO 153”.

Anyone? Does Ajax have a limit on the number of records it can pull? This course table maybe has 1200 courses, but why are they undefined?

  • 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-20T22:35:23+00:00Added an answer on May 20, 2026 at 10:35 pm

    You’re retrieving the name, but when searching for a course, the name has been renamed to course. You can fix this in the PHP by changing this line:

    $arr[] = array( "id" => $row["cID"], "course" => $row["prefix"] . ' ' . $row["code"]);
    

    To this:

    $arr[] = array( "id" => $row["cID"], "name" => $row["prefix"] . ' ' . $row["code"]);
    

    Also, unrelatedly, in the JavaScript, you are setting ext without declaring it. You should probably change this line:

    var phppage;
    

    To this:

    var phppage, ext;
    

    Edit: This is how you would style the items as a proper bulleted list:

    var content=$("#content");
    var ul=$("<ul>");
    content.append(ul);
    $.each(data, function(){
        ul.append('<li><a href="' + phppage + ext + this.id + '">' + this.name + "</a></li>");
    });
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have two web applications that live on different web servers but if you're
Skip to live example. So basically I have a <div> that has a fixed
Basically I have a small template that looks like: <xsl:template name=templt> <xsl:param name=filter />
Basically you have two ways for doing this: for (int x = 0; x
We currently have a Live ASP.NET application (Basically a CMS) running on our IIS7
I have a HTTP Live streaming server setup that serves segmented mp3 audio content
I have a Facebook application that I've now put live, but I need to
Basically I have a Repository that controls access to my EF model. It creates
I have seen a few companies recently that are releasing live email content. This
So I basically have two textboxes in the aspx file which get populated by

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.