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
https://forums.phpfreaks.com/topic/244110-referencing-a-row-number-in-result-set/
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++;
     }
}

Archived

This topic is now archived and is closed to further replies.

×
×
  • 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.