View Single Post
Old 09-16-2021, 01:20 PM  
Publisher Bucks
Confirmed User
 
Industry Role:
Join Date: Oct 2018
Location: New Orleans, Louisiana. / Newcastle, England.
Posts: 1,125
Quote:
Originally Posted by k0nr4d View Post
Your description is still incredibly confusing, but there is no other replace query in mysql.
You can do this with php

Code:
$replace = array("cat","dog","fish");
$with = "zombie";
$result = mysqli_query($dblink,"SELECT animal,id FROM pets");
while($row = mysqli_fetch_assoc($result)) { 
   $row['animal'] = mysqli_real_escape_string($dblink,stri_replace($replace,$with,$row['animal']));
   mysqli_query($dblink,"UPDATE pets SET animal = '".$row['animal']."' WHERE record_num = '".$row['id']."'");
}
Okay, guess I need to write out all the different values to replace in $replace = array

Thank you for the help, I appreciate it
Publisher Bucks is offline   Share thread on Digg Share thread on Twitter Share thread on Reddit Share thread on Facebook Reply With Quote