...

View Full Version : mysql_data_seek not working on first record



mathceleb
11-10-2010, 09:38 PM
I have a mysql recordset below:



$qryRsltT0 = mysql_query($barryq,$dblinkT0);
while ($row = mysql_fetch_array($qryRsltT0)){
$pcount++;
mysql_data_seek($qryRsltT0,$q);
echo $row['name'];
if ($pcount==2) {break;}
}

This returns:
Person A
Person B
Person C
Person D

Those are all 4 of my records. However, using mysql_data_seek, the first loop of returning the recordset always chooses the first record, and then gets the $q index correct after the first loop


$pcount=0;
$q=2;
$qryRsltT0 = mysql_query($barryq,$dblinkT0);
while ($row = mysql_fetch_array($qryRsltT0)){
$pcount++;
mysql_data_seek($qryRsltT0,$q);
echo $row['name'];
if ($pcount==2) {break;}
}

This returns:
Person A
Person C

How would I make the first round of looping correct to get it to pick the $q index?

MattF
11-10-2010, 09:47 PM
You need to seek before you start looping.



mysql_data_seek($qryRsltT0,$q);

while ($row = mysql_fetch_array($qryRsltT0)){

mathceleb
11-10-2010, 10:37 PM
Thanks, that worked.



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum