Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

difficulty adding whitepace between two strings concatted from DB in HTML form drop down menu

Tags:

I am pulling data from 2 DB columns in same table to populate drop down menu in HTML form. Although I do get both pieces of data, I cannot seem to concat them with white space separate them. The code below is my general attempt to do so, but I have tried changing and omitting quotes for the whitespace as well as enclosing firstname and lastname in single and double quotes. But nothing seems to work. I am left thus far with: Firstnamelastname.

<?php
        //db connection
            mysql_connect('localhost', 'root', "");
            mysql_select_db('recy');

            $sql = "SELECT CONCAT(firstname,' ',lastname) FROM technicians";
            $result = mysql_query($sql);

            echo "<select name='firstname',' ','lastname'>";
            while ($row = mysql_fetch_array($result)) {
                echo "<option value'" . $row['CONCAT(firstname,' ',lastname)'] . "'>" . ucwords($row['CONCAT(firstname,' ',lastname)']) . "</option>";
            }
            echo "</select>";
        ?>

Any advice or suggs appreciated.