I am trying to update certain Text inside of mysql rows. The "action" row contains things like "Username Logged in", "Username made a comment", etc.
So the idea is if a User changes their Username I want to update the "action" row to reflect it. So it would be "Newusername Logged in", "Newusername made a comment", etc.
Here's what I have right now:
$get_text = "SELECT * FROM activity WHERE username = '{$userinfo_username}'";
$get_result = mysql_query($get_text);
while ($row = mysql_fetch_assoc($get_result)){
$action_text = $row['action'];
$new_action_text = str_replace($userinfo_username,$_POST['username'],$action_text);
$query = "UPDATE activity SET
action = '{$new_action_text}'
WHERE username = '{$userinfo_username}'";
$result=mysql_query($query);
}
This updates all "action" rows the correct Username but replaces the entire text as well.
I hope this makes sense