First: use mysqli functions or the PDO class, not mysql functions, they are deprecated.
Second: use long PHP tags
But you are on the right track:
Replace the first line as follows:
$mosque_id = (isset($_GET['mosque_id']) ? intval($_GET['mosque_id']) : 1);
And in the end
<input type="button" value="Next Mosque" onclick="javascript: document.location = '?mosque_id=<?php echo ($mosque_id + 1);?>"/>
You also need to write some checks after the request, if such an identifier exists and in fact, if you develop further, you also need to check the following mosque_id, since if you delete several lines, id-s may not be in the correct order as 1, 2, 3, 4, but 1, 3, 7, 9 (hint: for the next use id WHERE mosque_id> current_id ORDER BY mosque_id DESC LIMIT 1 in MySQL)
source share