Forum Moderators: coopster

Message Too Old, No Replies

getting next records

         

naghme

4:36 pm on Jun 7, 2003 (gmt 0)

10+ Year Member



hi
first let me describe the situationa :
DB is in access and i use odbc to work with it.
in my script i have :
$SqlStr="select * from TB where fld1=X"
if($connect=odbc_connect($odbc,$user,$password))
{
if ($result=odbc_exec($connect,$SqlStr))

$End=odbc_fetch_row($Result);
while($Counter<10 and $End<>null )
{
if ($End<>null)
{
echo(odbc_result($Result,1));
}
$Counter=$Counter+1;
$End=odbc_fetch_row($Result);

}
}

so with this we can see first 10 records,now we want to see next 10 records,i dont know how
can i pass this parameter to odbc_fetch_row since the driver dose not support it.
(in my local computer it is supported and i see the result but when i upload it i dont get any answer and also no error )

any suggestion how to solve it is appreciable
naghme

jatar_k

4:43 pm on Jun 7, 2003 (gmt 0)

WebmasterWorld Administrator 10+ Year Member



Why not pass an offset like the id of the last row you displayed and then start from there, display 10 and store the next offset.

naghme

2:17 pm on Jun 8, 2003 (gmt 0)

10+ Year Member



thank you for your reply , but i did not get what you said, could you pls kindly explain more.

thank you
naghme

daisho

2:32 pm on Jun 8, 2003 (gmt 0)

10+ Year Member



If the backend database is MySQL you could use the Limit modifier.

SELECT * FROM table LIMIT 10; // First 0-9 records
SELECT * FROM table LIMIT 10, 10; // 10-19

If you are using Oracle lookup the ROWNUM pseduo column. It's a little tricky to get from 10-19 and so on but it can be done.

daisho.

jatar_k

7:19 pm on Jun 9, 2003 (gmt 0)

WebmasterWorld Administrator 10+ Year Member



Expanding on that with a unique id you could do something like

first page
$query = "SELECT * FROM table LIMIT 10";

as you display the records you keep the id of the last record displayed and then pass it on to the next page.

next page
$query = "SELECT * FROM table where id > " . $lastid . " order by id LIMIT 10";