Only ID next and prior laws if they exist

This suppresses a PHP notice.