Jump to content

[SOLVED] Text Field and Space before Last Name in DB


TecTao

Recommended Posts

I am use to useing the tab key when filling in forms.  I've created a form with a Last Name field.  When I tab the curser is justified left completely, so when I enter a name and submit there is no space before the letter of the last name.  So when I search by letter of the last name, the name comes up in the query.

 

But I found that if I manually put the curser in the field with my mouse, it automatically puts a space before the first letter of the name, so when submitted in the DB, there is a space and when searching my last name the name doesn't come up in the query.

 

What can be done to strip away any spaces prior to submitting int the DB, or forcing a left justify in the form prior to submitting?

 

Thanks for any help or suggestions in advance.

Link to comment
Share on other sites

I've been reading up on the trim() and the ltrim() and that makes sense.  I'm not sure where I would place it.

 

The form with the text field is passing the variable.  The second page inserts the name in the db with an insert query.

 

The search page is an alphabetical search with list of hyperlinks such as:

 

<a href="b_query_name.php?letter=A">A</a>

 

 

the b_query_name.php page has this code:

 

<input type="hidden" name="ud_id" value="<? echo "$letter" ?>">

<?

include($DOCUMENT_ROOT .'/include/db_connect.php')

$result = mysql_query( "SELECT * FROM network_members WHERE lName LIKE '$letter%' ORDER BY lName ASC" )

?>

 

Is the trim() placed in the sql statement or of the select or insert.  Sorry, but a bit confused because if there is a space before a last name such as Adams, Adams won't be returned since the query doesn't see the "A".  I hope this makes sense.

 

Link to comment
Share on other sites

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.