Go Back   CodingForums.com > :: Server side development > PHP

Before you post, read our: Rules & Posting Guidelines

Reply
 
Thread Tools Rate Thread
Enjoy an ad free experience by logging in. Not a member yet? Register.
Old 11-10-2010, 08:38 PM   PM User | #1
mathceleb
Regular Coder

 
Join Date: Mar 2010
Posts: 235
Thanks: 39
Thanked 6 Times in 6 Posts
mathceleb is an unknown quantity at this point
mysql_data_seek not working on first record

I have a mysql recordset below:

PHP Code:
$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

PHP Code:
$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?
mathceleb is offline   Reply With Quote
Old 11-10-2010, 08:47 PM   PM User | #2
MattF
Senior Coder

 
Join Date: Jul 2009
Location: South Yorkshire, England
Posts: 2,322
Thanks: 6
Thanked 304 Times in 303 Posts
MattF will become famous soon enoughMattF will become famous soon enough
You need to seek before you start looping.

Code:
mysql_data_seek($qryRsltT0,$q);

while ($row = mysql_fetch_array($qryRsltT0)){
MattF is offline   Reply With Quote
Users who have thanked MattF for this post:
mathceleb (11-10-2010)
Old 11-10-2010, 09:37 PM   PM User | #3
mathceleb
Regular Coder

 
Join Date: Mar 2010
Posts: 235
Thanks: 39
Thanked 6 Times in 6 Posts
mathceleb is an unknown quantity at this point
Thanks, that worked.
mathceleb is offline   Reply With Quote
Reply

Bookmarks

Jump To Top of Thread


Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT +1. The time now is 05:45 PM.


Advertisement
Log in to turn off these ads.