Re: results over multiple pages

From: Date: Tue, 07 May 2002 04:04:31 +0000
Subject: Re: results over multiple pages
References: 1  Groups: php.windows 
Request: Send a blank email to php-windows+get-13586@lists.php.net to get a copy of this message
Does MSSQL not have a LIMIT clause? $offset = ($page - 1) * $numDisplay i.e. SELECT * FROM $table WHERE whatever = '$blah' LIMIT $offset, $numDispay olinux --- RS Herhuth <ronherhuth@mindspring.com> wrote: > List, > > I'm pulling my hair out trying to figure out why > this is not working. I am > trying to limit the number of returns on a page and > if need be spread the > results over multiple pages. The following is where > i believe the problem > to be. Please keep in mind I'm using Microsoft SQL > Server. The variables > are being set properly (I have several places where > I'm echoing the results > just to be sure). The problem is that the same five > names are being > returned on each page even though the value of $i is > incrementing properly > and the correct number of pages are being calculated > correctly. > > > > > if ($currentPage > 1) { > $host="localhost"; > $DB="testDB"; > $user="sa"; > $pass=""; > $connect = mssql_connect($host,$user,$pass) or die > ($host." not > accessible."); > if ($DB) mssql_select_db($DB)or die('USE '.$DB.' > failed!'); > $query = "SELECT first_name, last_name FROM > individual WHERE last_name > LIKE '$searchField%' ORDER by last_name ASC"; > $result = mssql_query($query); > $numRows = mssql_num_rows($result); > $numPages = ceil($numRows/$numDisplay); > echo "Total Rows: $numRows, Results per Page: > $numDisplay, Number of > Pages: $numPages<br><br>"; > $lwr = $currentPage * $numDisplay; > $upr = ($currentPage * $numDisplay) + $numDisplay; > echo "$lwr, $upr <br><br>"; > echo "Current Page: $currentPage<br><br>"; > for($i = $lwr; $i < $upr; $i++){ > $row = mssql_fetch_row($i,$result); > echo "$i, $row[first_name] $row[last_name]<br > />"; > } > > if($currentPage < $numPages){ > $nextPage = $currentPage + 1; > echo "<a > href='searchScreen.php?searchField=$searchField&currentPage=$nextPage'>next< > /a>"; > } > } > > > > > > > Anyone have any idea why only the same five names > might be being returned on > each of the pages? I'm not getting something here. > > Thanks, > Ron > > > -- > PHP Windows Mailing List (http://www.php.net/) > To unsubscribe, visit: http://www.php.net/unsub.php > __________________________________________________ Do You Yahoo!? Yahoo! Health - your guide to health and wellness http://health.yahoo.com

« previous php.windows (#13586) next »