int mysql_data_seek
(int result_identifier, int row_number);成功した場合に TRUEを、失敗の場合にFALSEを返します。
mysql_data_seek は、指定した結果ID (result_identifier) が指す MySQL 結果の内部ポインタが指定した行番号(row_number)を指すように 移動します。 この後、mysql_fetch_row をコールした場合には、 ここで指定した行の内容が返されます。
row_number は、0 から始まります。
例 1. MySQL データシークの例
<?php $link = mysql_pconnect ("kron", "jutta", "geheim") { or die ("Could not connect"); } mysql_select_db ("samp_db") { or die ("Could not select database"); } $query = "SELECT last_name, first_name FROM friends"; $result = mysql_query ($query) { or die ("Query failed"); } # 逆順に行を取得する for ($i = mysql_num_rows ($result) - 1; $i >=0; $i--) { if (!mysql_data_seek ($result, $i)) { printf ("Cannot seek to row %d\n", $i); continue; } if(!($row = mysql_fetch_object ($result))) continue; printf ("%s %s<BR>\n", $row->last_name, $row->first_name); } mysql_free_result ($result); ?>