PHP print dropdown list and select from the middle by default

I have a dropdown list that works fine, but halfway through the list of 80 values is the one I want as selected by default

$cosOptions = cos_options();

Is the variable

<td><select name="options"><?php print $cosOptions; ?></select></td>

Prints the dropdown, then the function below.

function cos_options()
    $dbh = dbh_get();
    $options = '';

    $sql = 'select code, descr FROM cos';
    $stmt = $dbh->prepare($sql);
    while (true) {
        $r = $stmt->fetch();
        if (is_bool($r)) break;
        $options .= '<option value="' . $r['code'] . ' ' . $r['descr'] . '">' . $r['code'] . ' ' . $r['descr'] . '</option>';

    return $options;

The Postgres table only has two columns and 80 rows

code descr

D1 Pizza

D2 Bread

D3 Cornflakes etc,.

What I need is D43 Rice to be selected at first because 90% of the time it will be this. How can I achieve this? I’ve gone through a bunch of posts on here but can’t get it working.

Source: stackoverflow-php

Javascript HTML select dropdown

I am trying to get the data from database and display it in select option through drop down menu. I am getting the data correctly in java script page as well. But it is not displaying in the drop down menu of html.

HTML code:

<td>Organization Name:</td>
                <td><select id="orgname" name="Oname" onload="getOrganizationname();">
                          <option selected disabled value=" ">Choose your Organization</option>

                        <!-- <option value="1" >xyz</option>
                        <option value="2">Brocade</option>
                        <option value="3">Citrix</option> --> 

Javascript code: function getOrganizationname() {

        document.getElementById("orgname").innerHTML= data;


onload i am getting this in alert msg(trying to debug) This is info. from database:
<option value="Infosys"></option>
<option value="Akamai"></option>
<option value="Brocade"></option>
<option value="XYZ"></option>
<option value="XYZ1"></option>
<option value="XYZ2"></option>
Appreciate your help in advance.

Source: stackoverflow-javascript