StanLytle Posted July 21, 2007 Share Posted July 21, 2007 I have a table named "Roster" with a field named "Lineage". The data in "Lineage" is input by users, and not always in the same format. What I want to do, is search for specific wording, and change only that portion. For example, I want to search all records where part of the lineage is "ex-AT&SF" and change it to "ex ATSF" without changing anything else in the field. How would the query be written? Thanks, Stan Quote Link to comment Share on other sites More sharing options...
StanLytle Posted July 21, 2007 Author Share Posted July 21, 2007 I know this isn't everything, and it won't work, but I think it might look something like: $sql = "SELECT Lineage FROM Roster"; $result = mysql_query($query) or die(mysql_error()); while ($myrow = mysql_fetch_array($result)) Lineage2 = str_replace("ex-ATSF","ex ATSF",Lineage); But I can't figure out how to write Lineage2 back into Lineage. Stan Quote Link to comment Share on other sites More sharing options...
fenway Posted July 27, 2007 Share Posted July 27, 2007 You can use replace (a mysql function), but you probably need to use the substring functions if the position is variable. 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.