Forum Moderators: coopster
I heard someone say i could "Change the SQL to "SELECT TOP 50...."
I'm not sure how to do that, can anyone help?
This is the code you may need
---------
/ build SQL
$strsql = "SELECT * FROM `database`";
if ($DefaultFilter <> "") {
$whereClause .= "(" . $DefaultFilter . ") AND ";
}
if ($dbwhere <> "" ) {
$whereClause .= "(" . $dbwhere . ") AND ";
}
if (substr($whereClause, -5) == " AND ") {
$whereClause = substr($whereClause, 0, strlen($whereClause)-5);
}
if ($whereClause <> "") {
$strsql .= " WHERE " . $whereClause;
}
if ($OrderBy <> "") {
$strsql .= " ORDER BY `" . $OrderBy . "` " . @$HTTP_SESSION_VARS["database_OT"];
}
//echo $strsql; // comment out this line to view the SQL
$rs = mysql_query($strsql);
$totalRecs = intval(@mysql_num_rows($rs));
The
LIMITclause can be used to constrain the number of rows returned by theSELECTstatement.LIMITtakes one or two numeric arguments, which must be integer constants. With two arguments, the first argument specifies the offset of the first row to return, and the second specifies the maximum number of rows to return. The offset of the initial row is 0 (not 1):SELECT * FROM table LIMIT 5,10; # Retrieve rows 6-15