I have posted this in Newbie section but did not get much help.. I am hoping someone here can help me out .. i am using PEAR's db object..
wanted to know how to reset resultsets basically lets say i have a :
rs_paper = $db->query($paperquery);
for ($i=0; $i < $rs_paper->numRows();$i++){
$row = $rs_paper->fetchRow(DB_FETCHMODE_ASSOC);
echo $row['papername'];
//code goes here
}
what i want to do again in the same page is
for ($i=0; $i < $rs_paper->numRows();$i++){
$row = $rs_paper->fetchRow(DB_FETCHMODE_ASSOC);
echo $row['papername'];
//code goes here
}
again
what seems to happen is the code remembers the numRows() which is obvious.. the for loops both execute..the first loop executes fine printing out echo $row['papername'];
but when the second for loop runs it does not produce any out put at echo $row['papername'];
as of what i understand i think the first for loop executes the resultset and puts the cursor at the end of the recordset..
what my question is what do i need to write between those 2 for loops so the resultset starts from beginning again...
would
$rs_paper->free();
rs_paper = $db->query($paperquery);
in the middle would be a prober solution?
thanks for your help in advance.