I have a function that fetches one or multiple rows from a database and in php, goes through a series of foreach loops to make a table body from it, like so:
function buildTableRowsByPCS($connection, $numbers) {
$body = NULL;
foreach($numbers as $number) {
$rows = getRowFromPCS($connection, $number);
$body .= '<tr>';
foreach($rows as $row) {
if(is_array($row)) {
$body .= '<td>';
foreach($row as $r) {
$body .= $r.'<br>';
}
$body .= '</td>';
} else {
$body .= '<td>'.$row.'</td>';
}
}
$body .= '</tr>';
}
return $body;
}
It is working fine, but, sometimes one of the columns has a cell of data that seems to be disturbing the html, whether it be a "/" or "<" or ">" etc. Which results in me getting a mismatch error in my datatable. Is there any way whether in php or sql to treat the data gotten as purely text and treat the characters in it as nothing to do with HTML etc?