I haven't been able to find a satisfactory answer for this one.
I have a database - company.csv using ODBC System DSN using Microsoft Text Driver. There is a unique field called stock which acts as a primary key. The problem is the stock numbers are not sequential - 1, 2, 3, 4, etc. - but are more like - 8012, 4567, 9043, 1238, etc. Since the stock numbers are not sequential, my pagination results are skewed and do not display correctly. Here's my sql statements for the pagination:
$query = "SELECT * FROM company.csv WHERE make = 'Chevrolet'";
$num_result = odbc_exec($db, $query);
$numrows = inv_rows($num_result);
$make = odbc_result($num_result, "make");
echo '<p>There are currently '.$numrows.' '.$make.' products in our inventory.</p>';
$limit = 10;
$limitvalue = $page * $limit - ($limit);
$limitnew = $limitvalue + $limit;
$sql = "SELECT TOP $numrows * FROM (SELECT TOP $numrows * FROM company.csv WHERE stock between '$limitvalue' and '$limitnew' AND make = 'Chevrolet' ORDER BY model, year, sellingprice ASC) ORDER BY model, year, sellingprice ASC";
$result = odbc_exec($db, $sql);
while(odbc_fetch_row($result)){
inv_rows() is a function defined earlier in the page
As I said, my pagination returns results, but in a rather random and chaotic order, and it also does not include every available record in the results. My question is this: How do I create a row number on the fly for each record, which I can then use in the above sql statement in place of "stock"? I think doing so will cause my pagination results to display correctly. Fast help would be appreciated. Thanks in advance.