Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 2 of 2
  1. #1
    New Coder
    Join Date
    Jan 2007
    Posts
    19
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Question Retrieving From Database the first word of a sentence

    I have a column named 'name' in my table 'TEAM'(Using Mysql).I have entered values such as

    Martin Davis
    Kiran Rathore
    Naveen krishnan
    Prajith V M

    I want these values to be retrieved in a PHP form as

    Martin
    Kiran
    Naveen
    prajith

    How to do this?Please help.

  • #2
    Senior Coder koyama's Avatar
    Join Date
    Dec 2006
    Location
    Copenhagen, Denmark
    Posts
    1,246
    Thanks
    1
    Thanked 5 Times in 5 Posts
    There are probably many ways. In your case this would suffice:
    PHP Code:
    $name 'Martin Davis';
    $words explode(' '$name);
    echo 
    $words[0];  // outputs 'Martin' 


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •