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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 28, 20262026-05-28T22:49:56+00:00 2026-05-28T22:49:56+00:00

Basically, I have populated a dropdown list using php from a database on a

  • 0

Basically, I have populated a dropdown list using php from a database on a page called admin.php.

I’m now using JQuery with Ajax so that when a surname is clicked from the dropdown menu.

It will call employerProfile.php and show it in the <div id="showEmployerProfile"> but my code doesn’t seem to be working.

There are no errors, just the function doesn’t want to work.

Here’s the JS:

//SHOW EMPLOYER PROFILE FOR ADMIN
$(".eNameData").click(function() {
var eNameData = $(this).val();
    var dataToSend = 'eName=' + eNameData;

    $.ajax({                
        url: "includes/employerProfile.php", 
        type: "POST",
        data: dataToSend,     
        cache: false,
        success: function(html)
        {
        $("#showEmployerProfile").show();
            }
    });
  }
);  

Here is the code for the admin.php:

 <script type="text/javascript" src="/js/jq.js">
 </script> 

  <div id="pMainDashBoard">

    <?php /*?>DROP DOWN MENU TO SELECT EMPLOYER<?php */?>

  <form id="employer" method="get">
    <select name = "selectEmployer" id = "selectEmployer">
          <?php

          include "database_conn.php";
          $sql = "SELECT surname FROM employer";
          mysql_query($sql) or die (mysql_error());
          $queryresult = mysql_query($sql) or die(mysql_error());

        while ($row = mysql_fetch_assoc($queryresult)) {
            $eName = $row['surname'];
            echo"<option value = \"$eName\">$eName</option>\n";
                        }
            mysql_free_result($queryresult);
            mysql_close($conn);
        ?>
      </select>
      </form>
   </p>

<div id ="showEmployerProfile">

 </div>

employerProfile.php:

employerProfile has $userID = $_GET[‘userID’]; then the database_conn.php. SQL query is stated as:

$query = SELECT * FROM employer WHERE userID = '$userID';

but has ” ” around the sql then every div following this statement is echo’ed and has ” ” around each tag.

        echo <div id=\"empName\">;
        echo <h2>;
        echo $row["forename"] .' ';
        echo $row["surname"];
        echo  - ;
        echo $row["position"];
        echo </h2>;
        echo </div>;




        echo <div id=\"employerHead\">;

        echo <div id=\"empCompName\">;
        echo <h2>Company Name</h2>;
        echo $row["companyName"];
        echo </div>;

                    ..blah blah

        echo "</div>";

}


?>

Any help is much appreciated, thank you.
T.J

  • 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-28T22:49:56+00:00Added an answer on May 28, 2026 at 10:49 pm

    It depends on what employerProfile.php looks like exactly, but assuming that it returns html (you are echoing html for example), you need to use that html to populate your showEmployerProfile div.

    So you would need to change:

    success: function(html)
        {
          $("#showEmployerProfile").show();
        }
    

    to something like:

    success: function(php_output)    // using a different name for clarity
        {
          $("#showEmployerProfile").html(php_output).show();
        }
    

    And you need to change the first part to something like:

    $("#selectEmployer").change(function() {
      var eNameData = $(this).val();
    

    That way you are reacting on changes in the dropdown selection.

    Edit: Based on your comment, you need to supply the userID to your ajax function and employerProfile.php. You would need to change how your select is built in admin.php:

    $sql = "SELECT userID, surname FROM employer";     // changed
    mysql_query($sql) or die (mysql_error());
    $queryresult = mysql_query($sql) or die(mysql_error());
    
    while ($row = mysql_fetch_assoc($queryresult)) {
        $eName = htmlspecialchars($row['surname']);    // changed
        $userID = intval($row['userID']);              // added, assuming userID is an integer
        echo"<option value = \"$userID \">$eName</option>\n";    // changed
    }
    

    Now your select options will have a value that corresponds to a userID.

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

Sidebar

Related Questions

Basically I have a drop down list which is populated with text and values
I'm using Ajax and jQuery to do some cool client-side stuff. Basically, if the
I have a datatable, transformersDT, populated with data from a database table. I'd like
I basically have a page which shows a processing screen which has been flushed
ok so I am trying to dynamically create a select list using javascript, basically
I have a list of ID numbers that I pull from a session variable
So, basically I have this select / drop down menu that I use AJAX
So I basically have two textboxes in the aspx file which get populated by
Basically I have a program which, when it starts loads a list of files
How do I navigate to a specific page programmatically. Basically I have an app

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.