I need to fetch two table columns from mysql & then replace part of contents of one column with contents of other. This is how I do but it shows nothing.
$query = "SELECT id, msg FROM msg2_qualities";
$result = mysql_query($query);
$outArray = array();
if ($result) {
while ($row = mysql_fetch_assoc($result))
{
$row2 = str_replace('testWord','$row[0]',$row[1]);
$outArray[] = $row2;
}
}
echo json_encode($outArray);
EDIT I tested the code by echo & $row[0], $row[1] have no value. But If I run query to fetch single column from table, then it works fine like
$query = "SELECT msg FROM msg2_qualities"; OR
$query = "SELECT id FROM msg2_qualities";