In this case, it might be better to check that $ld is an int, or cast it to an int, and then simply print the message, checking that $ld is in the range [0,5] if necessary. An example would be:
echo '<script type="text/javascript">' . "\n";
if ($ld >= 0 && $ld <= 5) {
echo 'alert (" have ' . $ld . ' reservation more!")';
} else {
echo 'alert("Error: wrong reservation quantity!")';
}
echo '</script>';
if i want case 1 to go to lend_book.php meanwhile case 1,2,3,4 and 5 go to select_book.php?
How do you want to direct the user to the other pages? Through a link, or perhaps HTTP redirection?