I have a mysql_query result that I am looping through multiple times in different parts of code, each time using a mysql_data_seek( $result, 0 ) to reset to the beginning of the result.
I am using mysql_fetch_array on those results, and would like to remove a few specific rows from the $result. Basically the equivalent to unset( $result[$row] ) if it was a normal array. Is there any way to do this?
Sample code:
$result = mysql_query( $sql );
$num_rows = mysql_num_rows( $result );
if( $num_rows ){
for( $a=0; $a < $num_rows; $a++ ){
$row = mysql_fetch_array( $result );
if( my_check_function( $row['test'] ){
// do stuff
} else {
// remove this row from $result
}
}
}
mysql_data_seek( $result, 0 );
I know I can simply do unset( $row[$a] ) to remove that specific row, but after the data seek and I loop through the results next time I end up with the same original result rows.
Any help would be appreciated. ps - Not sure why the _'s were removed in my top text and changed to italics, I tried to fix it but it ended up being bold.. :)