Jump to content

Trimming an email address


zonkd

Recommended Posts

I've a list of email addresses that I want to publish on a website. I want to extract the name before "@", then split it into two, and cap the first letter of both.

I plan to show the name and have it as a mailto with the address, of course,  in an <a href> situation.

Be very grateful for some guidance.

Cheers all

paul

Link to comment
Share on other sites

I want to extract the name before "@", then split it into two, and cap the first letter of both.

 

The explode() function can split the string on @ into two array elements

 

The ucfirst() function will convert the first letter of a string to upper case

Link to comment
Share on other sites

set @email := 'first@last.com';
select @email, SUBSTRING( @email, 1, INSTR(@email, '@'  ) - 1 ) AS user, SUBSTRING_INDEX(@email,'@',-1) AS host

 

It's a little ugly to then use another set of substring function to mimic ucfirst()....

Link to comment
Share on other sites

Fenway, genius says the label. May I borrow a little of it, please?

 

What I don't follow is how I would use this. I have a mysql select that puts the email address onto the page. Something like ...

 

 

$result = mysql_query("SELECT email_address, etc etc FROM etc WHERE etc");

 

 

Where would your code go here, please?

 

I know this is very basic, but I can't decide if you mean it should go round the record name or to be declared separately.

 

Hopefully

paul

Link to comment
Share on other sites

  • 2 weeks later...
This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.