- htmlentities: documentation ( source)
<?php
$results['id'] = 14;
$results['post_link'] = 'cold_duck';
?>
<button type="button" class="btn btn-sm btn-outline-secondary" onclick="window.location.href = '<?= htmlentities($results["id"], ENT_QUOTES) ?>/<?= htmlentities($results["post_link"], ENT_QUOTES) ?>'">View</button>