MySQL CONCAT_WS() Function[
^]
The above MySQL function will allow you to build the result you want:
SELECT
CONCAT_WS(" ", first_name, middle_name, last_name) AS FullName
FROM
Table1
WHERE
id=(some user id);
About the way to fetch and display the result in php, you just have to search for examples here on CP, or with your favorite search engine. Some examples:
php form prepared statement[
^]
PHP - Code Project[
^]