Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

re-positioning the query result

Status
Not open for further replies.

PeterMac

Programmer
Mar 9, 2001
51
0
0
CA
Hello everyone:

I have the following code that works, but the only way it is working is if I hit the database twice to get my $result array back to the top. It is the same query and all I want to do is put the "record pointer" back to the front of the array. I have tried reset(), but it does not seem to work. Any help appreciated.

===========
$result = mysql_query($sql, $connection) or die( "Could not execut sql: $sql");
$num_result = mysql_num_rows($result);

for ($i=0; $i < $num_result; $i++) {

$row = mysql_fetch_array($result);
$disp_array[$row[&quot;logid&quot;]] = &quot;no&quot;;
}

// re-hit the database with the same query to reset the record pointer to the first record
$result = mysql_query($sql, $connection) or die( &quot;Could not execut sql: $sql&quot;);
 
Yes, thanks... I have been looking for this for 2 days ! and as soon as I posted this question, I did one more search thru this site and found the answer. I have tried the code and it runs &quot;as smooth as a trout's ear&quot; !

Thanks for the quick response !

Cheers,
Peter
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top