You either need to submit the current slide number to the server - something like this:
<?php
function SlideShow($slide){
$conn = mysqli_connect("localhost", "root", "", "tsl_tv_system");
$image_details = mysqli_query($conn, "SELECT * FROM slides limit $slide, 1");
$row = mysqli_fetch_array($image_details);
echo "<img src='upload/upload/".$row['attachment_loc']."'>";
}
$n = isset($_POST['n']) ? intval($_POST['n']) : -1;
?>
<form method="post">
<input type="hidden" name="n" value="<?= $n >" />
<input type="submit" name="test" value="Next Image" />
</form>
<?php
SlideShow($n + 1);
?>
Or output all slides on the first request, and use Javascript to switch between them.