May 2005
Intermediate to advanced
352 pages
14h 39m
English
mysql_data_seek( )
void mysql_data_seek(MYSQL_RES *result, my_ulonglong offset)
Use this in
conjunction with mysql_store_result( ) and a fetch
function such as mysql_fetch_row( ) to change the
current row being fetched to the one specified in the second argument
of this function.
...
mysql_query(mysql, "SELECT client_id, client_name
FROM clients ORDER BY start_date");
result = mysql_store_result(mysql);
num_rows = mysql_num_rows(result);
mysql_data_seek(result, (num_rows - 8));
while((row = mysql_fetch_row(result)) != NULL)
{ printf("%s (%s) \n", row[1], row[0]); }
...This program excerpt retrieves a list of client names along with
their respective IDs. Using the mysql_data_seek( )
function in conjunction with mysql_fetch_row( )
and a while statement, the last eight clients who
started with the company will be displayed.
Read now
Unlock full access