PHP显示列表框FirstName和LastName

I am a new web developer by using PHP and MS SQL

I have already created my database on MS SQL as id, FirstName, LastName, etc.

I write a PHP to connect to my database with listbox (drop down) so I want to show FirstName

and LastName in my listbox but now I can show only FirstName

This is my code...

enter image description here

May anyone help me.

Thanks for you help.

You're only printing out the first name in the select box. Maybe try something similar to this.

while($name = $firstnameresult->fetch(PDO::FETCH_ASSOC)) {
    echo "<option value="" . $name['FirstName'] . "">" . $name['FirstName'] . " " . $name['LastName'] . "</option>";
}

if ur query result contains lastname too then u can use this

 echo '<option value="'.$name["Firstname"].'" >'.$name["Firstname"].' '.$name["Lastname"].'</option>';

Try this

echo '<option value="' . $name['FirstName'] . '">' . implode(' ', array($name['Firstname'], $name['LastName'])) . '</option>
';

i think you want this..try this code

echo '<select id="" name="" ">
   <option value="'.$row["First_name"].'">'.$row["First_name"].' '.$row["Last_name"].'</option>
     </select>';