extract first name from full name in database
I need to extract the first name from a full name database value to display it in an email. Any ideas how I can adjust a query to do this.
Thanks in advance!
I need to extract the first name from a full name database value to display it in an email. Any ideas how I can adjust a query to do this.
Thanks in advance!
It is probably easier to do it in php. Try adding this function to the page:
<?php
function first_name($name) {
$name = trim($name);
$last_name = (strpos($name, ' ') === false) ? '' : preg_replace('#.*\s([\w-]*)$#', '$1', $name);
$first_name = trim( preg_replace('#'.$last_name.'#', '', $name ) );
return $first_name;
}
?>
Then you can get the first name with something like:
<?php echo(first_name($Recordset->getColumnVal("fullNameColumn"))); ?>
I've tried to use this in an email file but it stops the email behaviour from working. It displays the email file in the browser instead of the web-page that contains the emails behaviour.
I've attached relevant pages.
Any ideas?
Thanks in advance!
Sorry I had a typo. split_name should have been first_name in the email body.
Your friends over here at WebAssist! These Dreamweaver extensions will assist you in building unlimited, custom websites.
These out-of-the-box solutions provide you proven, tested applications that can be up and running now. Build a store, a gallery, or a web-based email solution.