TecTao Posted February 21, 2007 Share Posted February 21, 2007 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. Quote Link to comment Share on other sites More sharing options...
tom100 Posted February 21, 2007 Share Posted February 21, 2007 Use the trim() function. http://www.php.net/manual/en/function.trim.php Quote Link to comment Share on other sites More sharing options...
TecTao Posted February 21, 2007 Author Share Posted February 21, 2007 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. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.