resetting record pointer

From: Date: Fri, 04 Aug 2000 06:13:59 +0000
Subject: resetting record pointer
Groups: php.general 
Request: Send a blank email to php-general+get-10075@lists.php.net to get a copy of this message
After issuing a mysql_fetch_array call, is it possible to reset back to the first row? I make the first call to pull out a few feilds for writing out titles, but then I want to loop through the entire resultset starting from the very beginning. Currently I go ahead and display the values from the first retrieved recordset, then put the others in a while loop. The problem is the code from displaying the first record set is duplicated inside the loop, which seems inefficient. // fetch first row for subject and category matter $qMsgRows = mysql_fetch_array( $rQuikNav ); println( "<TR><TD ALIGN=\"RIGHT\" CLASS=\"ColumnHead\" BGCOLOR=\"$cTableHead\">" ); println( "Subject: " . stripslashes( $qMsgRows["MSGSUBJECT"] ) . "<BR>" ); println( "Category: " . $qMsgRows["CATNAME"] ); println( "</TD></TR>" ); println( "<TR><TD CLASS=\"TableCells\">" ); println( "<TABLE ALIGN=\"LEFT\" BORDER=\"0\" CELLSPACING=\"0\" CELLPADDING=\"3\"BGCOLOR=\"Black\"><TR><TD>" ); println( "<TABLE ALIGN=\"LEFT\" BORDER=\"0\" CELLSPACING=\"1\" CELLPADDING=\"0\"BGCOLOR=\"$cTableHead\">" ); println( "<TR><TD CLASS=\"ColumnHead\">QuikNav</TD></TR>" ); // not inside the while loop, because we've already retrieved the first message println( "<TR>" ); print( "<TD CLASS=\"QuikNav\">" ); print( "<A HREF=\"#" . $qMsgRows["ID"] . "\" CLASS=\"QuikNav\">" ); println( date( "m/d/y", mysql2unix( $qMsgRows["MSGLASTACTIVITY"] )) . " by " stripslashes( $qMsgRows["MSGAUTHOR"] ) . "</TD>" ); println( "</TR>" ); // this starts at the second record set... duplicated from the code right above... ARGH! while ( $qMsgRows = mysql_fetch_array( $rQuikNav )) { println( "<TR>" ); print( "<TD CLASS=\"QuikNav\">" ); print( "<A HREF=\"#" . $qMsgRows["ID"] . "\" CLASS=\"QuikNav\">" ); println( date( "m/d/y", mysql2unix( $qMsgRows["MSGLASTACTIVITY"] )) . " by " .stripslashes( $qMsgRows["MSGAUTHOR"] ) . "</TD>" ); println( "</TR>" ); } Joseph E. Sheble a.k.a. Wizaerd Wizaerd's Realm Canvas, 3D, Graphics, ColdFusion http://www.wizaerd.com =================================

« previous php.general (#10075) next »