Instead of supressing the error I would try to fix it. Here is a revised version of your script. I've used the ternary operator (expr1) ? (expr2) : (expr3). As you see the script was reduced over 1/3 in number of lines.
PHP Code:
<?
$initStartLimit = 0;
$limitPerPage = 10;
$startLimit = isset($_REQUEST['startLimit']) ? $_REQUEST['startLimit'] : $initStartLimit;
$numberOfRows = isset($_REQUEST['rows']) ? $_REQUEST['rows'] : $limitPerPage;
$sortOrder = isset($_REQUEST['sortOrder']) ? $_REQUEST['sortOrder'] : 'DESC';
$sortBy = isset($_REQUEST['sortBy']) ? $_REQUEST['sortBy'] : '';
$newSortOrder = $sortOrder == 'DESC' ? 'ASC' : 'DESC';
$limitQuery = " LIMIT ".$startLimit.",".$numberOfRows;
$nextStartLimit = $startLimit + $limitPerPage;
$previousStartLimit = $startLimit - $limitPerPage;
if ($sortBy != "") {
$orderByQuery = " ORDER BY ".$sortBy." ".$sortOrder;
}
$sql = "SELECT * FROM libo_books" . $orderByQuery . $limitQuery;
$result = MYSQL_QUERY($sql);
$numberOfRows = MYSQL_NUM_ROWS($result);
if ($numberOfRows == 0) {
echo 'Sorry. No records found !!';
} elseif ($numberOfRows > 0) {
$i=0;
}
if ($_REQUEST['startLimit'] != "") {
echo "<a href=\"" , $_SERVER['PHP_SELF'] ,
"?startLimit=$previousStartLimit" ,
"&limitPerPage=$limitPerPage" ,
"&sortBy=$sortBy" ,
"&sortOrder=$sortOrder\">" ,
"Previous $limitPerPage Results</a>....";
}
if($numberOfRows == $limitPerPage) {
echo "<a href=\"" , $_SERVER['PHP_SELF'] ,
"?startLimit=$nextStartLimit" ,
"&limitPerPage=$limitPerPage" ,
"&sortBy=$sortBy" ,
"&sortOrder=$sortOrder\">" ,
"Next $limitPerPage Results</a>....";
}
-Helge
Bookmarks