Jump to content

Referencing a row number in result set


shamwowy

Recommended Posts

Hi all, dumb question I'm sure but not finding the answer so far...

 

I'm trying to reference the row number in a sql query resultset loop.

 

if( $r = mysql_query($query1) ) // LOTS AND LOTS OF ROWS RETURNED
{
     while( $row = mysql_fetch_assoc($r) ) // LOOP
     {
         print "Phone - {$row['jloc_phone']}<br/>";
         print "This is record number ".$what_var_here."<br/>"; //HOW TO REFENCE MY ROW NUMBER HERE?
     }
}									}

 

I've tried variations with $row and $r which return either "Array" or "resource". I'm assuming it's something like $row[count] or some such thing that I'm just not finding.

 

Many thanks in advance for any assistance on this.

Link to comment
Share on other sites

if( $r = mysql_query($query1) ) // LOTS AND LOTS OF ROWS RETURNED
{
     $counter = 1;
     while( $row = mysql_fetch_assoc($r) ) // LOOP
     {
         print "Phone - {$row['jloc_phone']}<br/>";
         print "This is record number ".$counter."<br/>"; //HOW TO REFENCE MY ROW NUMBER HERE?
         $counter++;
     }
}

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.