repeating a passage in a 'while' loop

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
dsdsdsdsd
Forum Commoner
Posts: 60
Joined: Fri Dec 05, 2003 3:10 pm

repeating a passage in a 'while' loop

Post 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
dsdsdsdsd
Forum Commoner
Posts: 60
Joined: Fri Dec 05, 2003 3:10 pm

Post 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
Post Reply