PHP: mssql_data_seek - Manual

downloads | documentation | faq | getting help | mailing lists | reporting bugs | php.net sites | links | conferences | my php.net

search for in the

mssql_execute mssql_connect

Last updated: Fri, 26 Jan 2007

view this page in

# mssql_data_seek

(PHP 3, PHP 4, PHP 5)

mssql_data_seek -- Moves internal row pointer

## Description

bool mssql_data_seek ( resource result_identifier, int row_number )

Возвращает `TRUE` в случае успешного завершения или `FALSE` в случае возникновения ошибки.

mssql_data_seek() moves the internal row pointer of the MS SQL result associated with the specified result identifier to point to the specified row number, first row being number 0. The next call to mssql_fetch_row() would return that row.

add a note User Contributed Notes
mssql_data_seek
phpcomments at hltools dot com
20-Jul-2005 04:33
`mssql_data_seek will return false AND trigger a warning ('Bad row offset') if you specify a row outside the result set.
You'll need to check beforehand if the row you are trying to seek to exists. Or you can supress the error and look for the false result, depending on your needs.
To check beforehand (where $result is the result fo your query and $seek is the row number you want to seek to):
<?php
$rowcount = mssql_num_rows($result);
if ($seek >= $rowcount)
{
print ("Trying to seek outside result set!");
}
else
{
if (!mssql_data_seek($result, $seek))
{
print ("Seek failed");
}
else
{
print ("Seek complete");
}
}
?>
To have a 'simpler' way of handling errors by supressing the warning:
<?php
if (!@mssql_data_seek($result, $seek))
{
print ("Seek failed");
}
else
{
print ("Seek complete");
}
?>`
add a note
mssql_execute mssql_connect

Last updated: Fri, 26 Jan 2007
show source | credits | stats | sitemap | contact | advertising | mirror sites
Copyright © 2001-2007 The PHP Group
All rights reserved.
This mirror generously provided by: Yahoo! Inc.
Last updated: Sat Mar 10 10:36:09 2007 PST