Dynamic php form with composite dropdown

WordPress 4.4.2
PHP 5.6

Hi

Read More

I have created a form that contains several dynamic dropdowns.
For the moment the form works, thought the coding could be a lot better.

My question concerns the breeder dropdown which displays the breeders last name. However several breeders may share the same last name so I’d like the dropdown box to show title + first name + last name.

I’ve fiddled about with the “.$row->owner_l_name.” bit but without success.

Thanks in advance

Gary

    <p><label for="Nom de l'éleveur">Nom de l'éleveur:</label>

<?php   
    // RETURN LIST OF BREEDERS
    //------------------------                               
        global $wpdb;

        $wpdb->show_errors();


        $query = "SELECT owner_id, title, owner_l_name, owner_f_name
                    FROM 0_bpi_owner
                    WHERE breeder_yn LIKE 'Y'
                    AND active LIKE 'Y'
                    and member_YN LIKE 'Y'
                    ORDER BY owner_l_name";


        $results = $wpdb->get_results($query);

?>
        <select name='owner'>
        <option value=' '</option>   
<?php       foreach($results as $row) 
            {
                echo '<option name="owner" value="'.$row->owner_id.'">'.$row->owner_l_name.'"</option>';
            }
 ?>
        </select>

Related posts