can't figure out how to implement the LIMIT clause
I have a grid that works perfect, almost...
I would like to use the LIMIT clause to only display the top 5. I have it ordering properly, but it shows all the records, not the top 5. Can someone please help me get the LIMIT 0,5 to work properly?
<?phpsession_start();if(!isset($_SESSION['id'])){ header("location:login.php"); }else{ $id = $_SESSION['id']; }//echo "$id";require 'connections/class.eyemysqladap.inc.php';require 'connections/class.eyedatagridPORTFOLIO.inc.php';$db = new EyeMySQLAdap('host', 'user', 'password', 'name');$x = new EyeDataGrid($db);$where = "id=$id";// Set the query$x->setQuery("Symbol,Full_Name,Industry,Affiliation,Current_Value,Movement,id", "portfolio", "", "$where");// Hide ID Column$x->hideColumn('id');// Allows filters$x->allowFilters();// Change column type$x->setColumnType('Symbol', EyeDataGrid::TYPE_HREF);$x->setColumnType('Industry', EyeDataGrid::TYPE_IMAGE);?>
okay, that actually returns 5 records per page, but I only want 5 records returned total.
kavik379
Ok. Using the code as is, I don't think it is possible to do what you want. If you notice in the first line of code in the method printTable, the lower limit is set according to the page number, so it will always change, thus changing the limit.
Thanks Roads Roads,
I tried that, it still gives me all of the records, it just shows whatever value I give.
$this->limit['Low'] = 0;
The problem is there are over 1000 records and I only want to show the top 10, I fear this might slow down the site over time. As an alternative, I am just hiding the footer which allows you to toggle through pages.
it sucks I know.
Lukasz Chmielewski
Well, I'm just a curious type of guy. But I suspect there IS a solution to that :P
$x-> setResultsPerPage(5);