Page 1 of 1

repeating a passage in a 'while' loop

Posted: Sat Nov 06, 2004 8:49 am
by dsdsdsdsd
hello;

I have:

Code: Select all

while ( $row = mysql_fetch_array($result_of_a_query,MYSQL_ASSOC) )
  { if ( $row[column_A] == "shhh" )
      { print "shhh";
      };
    if ( $row[column_A] == "boo" )
      { print "boo";
      };
    if ( $row[column_A] == "booger" )
      { $row[column_A] = "boo";
          then re-do this passage;
       };
I would like to be able to re-evaluate a passage through a loop;

in this example I could ofcourse have placed '...==boo' after the '...==booger' and it would work but this is just a poor example;

my issue is to have the ability to re-evaluate some passage through a while loop, specifically a while loop that is founded on the mysql_fetch_array function;

any thoughts;

thanks
Shannon Burnett
Asheville NC USA

Posted: Sat Nov 06, 2004 8:56 am
by dsdsdsdsd
once I posted my question I realised how obvious the answer is:

Code: Select all

while ( $row = mysql_fetch_array($result_of_a_query,MYSQL_ASSOC) )  
  { do_it ( $row[column_A]);
  };
function do_it($row[column_A] )
{ if ( $row[column_A] == "shhh" )      
    { print "shhh";      
     };   
   if ( $row[column_A] == "boo" )      
    { print "boo";      
     };    
   if ( $row[column_A] == "booger" )     
    { $row[column_A] = "boo";         
       do_it( $row[column_A] ) 
    };
thanks
dsdsdsdsd