Hi Guys, I'm trying to figure out on how can i translate the codes I've created in php mysql to php sqlsrv.Basically, I used LIMIT in MySQL to limit the pagination. However, this is not supported in SQL Server and I'm really having a hard time like 3 months already to figure this out.Below is the MySQL Code I wanted to translate on SQLSRV:$start="";$per_page = 1;$start = $_GET['start'];$max_pages = ($foundnum / $per_page);if(!$start)$start=0; $getquery = mysql_query("SELECT * FROM knowledgebase WHERE $construct LIMIT $start, $per_page");
And below code is what I currently have issues running in SQLSRV:$start="";$per_page = 1;$start = $_GET['start'];$max_pages = ($foundnum / $per_page);if(!$start)$start=0; $construct1 ="SELECT * FROM ENSEMBLE WHERE $construct";$run1=sqlsrv_query($con,$construct1, array(), array('scrollable' => 'keyset'));
I can easily add LIMIT in the line of code $construct1 ="SELECT * FROM ENSEMBLE WHERE $construct"; but I didn't do it as it is not possible anyway.TOP is the equivalent of LIMIT in sql server: http://www.w3schools.com/sql/sql_top.aspIt does work somehow when I type in:$construct1 ="SELECT TOP $per_page * FROM ENSEMBLE WHERE $construct";
but when I add $start:$construct1 ="SELECT TOP $start, $per_page * FROM ENSEMBLE WHERE $construct";
It gives me an error message saying..Warning: sqlsrv_fetch_array() expects parameter 1 to be resource, boolean given in C:\xampp\htdocs\trueensemble\search1.php on line 51I decided running error reporting after that to get a detailed error and I got:[SQL Server]Incorrect syntax near ','. )I tried removing comma, now gives me an error message:[SQL Server]Incorrect syntax near the keyword 'FROM'. )Anyone can kindly help me out on how I can possible translate or rewrite it? TIA.