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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 2, 20262026-06-02T07:15:49+00:00 2026-06-02T07:15:49+00:00

I am trying veru hard, to get results from a database to be displayed

  • 0

I am trying veru hard, to get results from a database to be displayed as a drop down list.

Basically I am fetching the foreign key, its unique code and its name/title. I need to display it as a drop down list, to be entered correctly into a new table

        $sql = "SELECT quali_code, title FROM `qualifications`  ";
    $result = mysql_query($sql, $this->connection);
    $result_array = array();
    while($r=mysql_fetch_array($result))
    {
    $result_array[$r['quali_code']][] = $r;
    }
    return $result_array;

With that I would need to create a drop down list in HTMl/PHP to select the title from, but obviously storing the value. sort of <list name=array[title] value=array[code] >

At the moment I am already stuck at returning my SQl result in an array that works for me, and have no clue how I will then populate a dropdown list with the correct array results.

Sample code above on how i fetch the sql results and here how my array looks like:

Array ( [AAT] => Array ( [0] => Array ( [0] => AAT [quali_code] => AAT [1] => AAT qualification [title] => AAT qualification ) ) [A_lev] => Array ( [0] => Array ( [0] => A_lev [quali_code] => A_lev [1] => A levels [title] => A levels ) ) [HNC] => Array ( [0] => Array ( [0] => HNC [quali_code] => HNC [1] => Fdsc/HNC [title] => Fdsc/HNC ) ) [Lan_ISLT] => Array ( [0] => Array ( [0] => Lan_ISLT [quali_code] => Lan_ISLT [1] => EISLT Qualification [title] => EISLT Qualification ) ) [Lan_qua] => Array ( [0] => Array ( [0] => Lan_qua [quali_code] => Lan_qua [1] => Language qualification [title] => Language qualification ) ) [Nat_Dip] => Array ( [0] => Array ( [0] => Nat_Dip [quali_code] => Nat_Dip [1] => National Diploma [title] => National Diploma ) ) ) 

Bare in mind I am totally new to PHP. Any help would be appreciated. But this array looks useless to me, and am not sure how to populate a list. The file where I fetch the result / array, is not the location where I populate the array into a list.

Many thanks for any hints on this matter

  • 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-02T07:15:50+00:00Added an answer on June 2, 2026 at 7:15 am

    Assuming all you’re trying to do is echo these rows into a dropdown:

    $sql = "SELECT quali_code, title FROM `qualifications` ORDER BY title ";
    $result = mysql_query($sql, $this->connection);
    while($r=mysql_fetch_array($result))
    {
    $quali_code = $r['quali_code'];
    $result_array[$quali_code][] = $r['title'];
    }
    
    
    echo "<select name='x'>";
    foreach($result_array as $q_code => $value)
    {
        foreach($value as $title) {
        echo "<option value='" . $q_code . "'>" . $title . "</option>";
        }
    }
    echo "</select>";
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Trying to get parameters from a PUT request using HttpServlet#doPut: public void doPut(HttpServletRequest request,
Trying to programmatically add options to a SELECT drop down in IE Windows Mobile.
Trying to find some information on this but am unable to get any results
Trying to insert data in database from edittext in android but data is not
Trying to get a list of all possible combinations of 2 arrays passed in
Trying to do this with a single query, but want to get a list
Trying to generate XML file from returend SQL query results. The SQL query returns
Trying to get comfortable with jQuery and I have encountered some sample code that
Trying to pull a value from the sunrise element from [yweather:astronomy] in the Yahoo
Trying to read registry keys remotly (from a host on local intranet)... All the

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.