Zergman Posted November 8, 2009 Share Posted November 8, 2009 Hey all, got a problem. Please be kind against my barbaric code I have a textbox that will search the employee database by entering in the employee ID and it will return the result on the same page. Query if(isset($_GET['findagentid']) && $_GET['findagentid']<>""){ $emp_id = $_GET['findagentid']; mysql_select_db($database_cnccoems, $cnccoems); $query_rsagentquery1 = "SELECT tblEmployees.employee_pdl_mgr_id, tblManagerOverrides.manager_id, tblEmployees.employee_first_name, tblEmployees.employee_last_name, tblEmployees.employee_id FROM tblEmployees LEFT JOIN tblManagerOverrides ON tblEmployees.employee_id = tblManagerOverrides.employee_id WHERE tblEmployees.employee_id LIKE '%$emp_id%' "; $rsagentquery1 = mysql_query($query_rsagentquery1, $cnccoems) or die(mysql_error()); $row_rsagentquery1 = mysql_fetch_assoc($rsagentquery1); $totalRows_rsagentquery1 = mysql_num_rows($rsagentquery1); if(!is_null($row_rsagentquery1['manager_id'])){ $manager_id=$row_rsagentquery1['manager_id']; } else { $manager_id=$row_rsagentquery1['employee_pdl_mgr_id']; } } Form <form method="get" id="agentretrieval" action="callDetail1.php"> <table align="center" cellpadding="2" cellspacing="0"> <tr> <td><div align="right">Find Agent Info :</div></td> <td><div align="left"><input type="text" name="findagentid" id="findagentid" class="textboxstyle" size="10" maxlength="7" /> (Digits Only)</div><div class="accenttext"><?php echo $tNGs->displayFieldError("NS_data", "flagentTID"); ?></div> <div align="left"><input type="submit" class="button1" name="findagentbutton" id="findagentbutton" value="Find" /></div></td> </tr> </table> </form> This works great if entering in digits only like 845787 as they are stored in the database like 00845787. Problem I have is that the ID's are sometimes retrieved by users from another DB with a letter infront of the numbers (eg t845787 or x845787) in one database, but the one I retrieve from has no letter in front. Hard to explain. Basically Im trying to accomplish this. They can put t845787 in the text box, hit search and it will strip off the t or x from the ID and search the database. Did I explain that right? Can't figure this out Quote Link to comment https://forums.phpfreaks.com/topic/180794-solved-remove-letter-from-numeric-textbox/ Share on other sites More sharing options...
.josh Posted November 9, 2009 Share Posted November 9, 2009 $string = preg_replace('~[a-z]~i','',$string); Quote Link to comment https://forums.phpfreaks.com/topic/180794-solved-remove-letter-from-numeric-textbox/#findComment-953952 Share on other sites More sharing options...
Zergman Posted November 9, 2009 Author Share Posted November 9, 2009 $string = preg_replace('~[a-z]~i','',$string); Thanks for the reply and code! but im not sure how to implement that. Sorry, still learning this crazy php stuff How would I use that in my code? Quote Link to comment https://forums.phpfreaks.com/topic/180794-solved-remove-letter-from-numeric-textbox/#findComment-953956 Share on other sites More sharing options...
.josh Posted November 9, 2009 Share Posted November 9, 2009 you would replace $string with whatever variable has your id. Quote Link to comment https://forums.phpfreaks.com/topic/180794-solved-remove-letter-from-numeric-textbox/#findComment-953957 Share on other sites More sharing options...
Zergman Posted November 9, 2009 Author Share Posted November 9, 2009 Sorry, that makes total sense now. Thank you for the help Quote Link to comment https://forums.phpfreaks.com/topic/180794-solved-remove-letter-from-numeric-textbox/#findComment-953965 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.