Jump to content

Changing only part of field data


StanLytle

Recommended Posts

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

 

Link to comment
https://forums.phpfreaks.com/topic/61131-changing-only-part-of-field-data/
Share on other sites

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

 

Archived

This topic is now archived and is closed to further replies.

×
×
  • 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.