I have a table with information on plants, with a field in it called state.
A plant can be in many states, so i have a value in the field 'CA LA WI' and so on, for example. Then, if i'm looking for plants in the area, i select where state like %CA% and get the plants that way, displaying the results with my php page in a table.
Is there a way to delete a value from the field, say, delete LA from the value above?
Thanks
multiple values in a field of a record
Moderator: General Moderators
-
andycruickshank
- Forum Newbie
- Posts: 10
- Joined: Tue Mar 23, 2004 6:12 am
- Location: Aberdeen
-
litebearer
- Forum Contributor
- Posts: 194
- Joined: Sat Mar 27, 2004 5:54 am
you might try this
be sure to keep a space after EVERY state INCLUDING the last one.
Code: Select all
<?PHP
// get the value from the database
$old = "CA LA MI OR WA ";
// enter the Abbreviation for the state to be removed
// into a variable -- make sure you include a space
$state = "MI ";
$new = str_replace($state, "", $old);
echo $old;
echo "<br>";
echo $new;
// update the record in the database
?>