Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 9142999
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 17, 20262026-06-17T09:54:56+00:00 2026-06-17T09:54:56+00:00

I have been racking my brain around this for a few hours. Basically I

  • 0

I have been racking my brain around this for a few hours. Basically I have a div that displays user info from a database:

if (isset($_SESSION['email']) && ($_SESSION['userID'])) {

$sql = "SELECT * FROM user_accounts WHERE email='" . $_SESSION['email'] . "' AND user_id=" . $_SESSION['userID'] ;
$userRecordSet = $_dbConn->query($sql);

if ($userRecordSet != NULL) {
    $userRow = $userRecordSet->getrow();
    $firstName = $userRow['first_name'];
    $lastName = $userRow['last_name'];

    }

}

The first and last name are then placed into the div and displayed to the user.

<div id="nameChange" title="Click to edit"><?=$firstName?> <?=$lastName?></div>

when the user clicks on this DIV element it converts into a text box, and displays the contents of the user’s first and last name taken from the DIV. here is the Jquery to support the above.

//execute when nameChange DIV is clicked
        $("#nameChange").click(function(){  

                //check if there are any existing input elements
                if ($(this).children('input').length == 0){


                    $("#save").css("display", "inline");

                    //variable that contains input HTML to replace
                    var inputbox = "<input type='text' class='inputbox' name='userName' value=\""+$(this).text()+"\">"; 
                    //insert the HTML intp the div
                    $(this).html(inputbox);         

                    //automatically give focus to the input box     
                    $("this .inputbox").focus();


                }               
        });

Doing this creates an issue with the database because I want the first and last name to go into separate columns but after it is converted into a text box, the contents are placed into a single variable. now for the question.

how can I parse through the text box and assign 2 separate variables for the first and last name?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-17T09:54:57+00:00Added an answer on June 17, 2026 at 9:54 am

    This assumes that your final parsing to the database is done with php.

    here are two function I use to get the first and last name form a text input:

    //returns first name form full name input
    public function FirstName($input)
        {   
            $name = explode(" ",$input);
            $howmany = count($name);
            if($howmany != '1')
                {
                if($howmany == '2')
                    {   
                        $firstname = $name[0];
                        return $firstname;
                    }
                        if($howmany == '3')
                    {   
                        $firstname = $name[0]." ".$name[1];
                        return $firstname;
                    }
                }
    
            return false;   
        }
    //returns last name from full name input
    public function LastName($input)
        {   
            $name = explode(" ",$input);
            $howmany = count($name);
            if($howmany != '1')
                {   
                    $last = $howmany -1;
                    $lastname = $name[$last];
                    return $lastname;
                }
            return false;   
        }
    

    This takes into account people that have two first names such as ” mary lynn”

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have been racking my brain on this one for hours now and I
In trying to parse a date, I have been racking my brain for hours:
I've been racking my brain over this for the past few days and I'm
Okay I have been racking my brain trying to build a JSON array from
I have been racking my brain for a few days trying to get a
I have been racking my brain all morning with this. I am using Eclipse
I've been racking my brain with this one. I have two arrays: Array 1
I have been racking my small brain for ages now, so can this be
I have been racking my brain (not hard to do) trying to figure this
I have been racking my brain over this all day today. I have the

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.