Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 1 of 1
  1. #1
    Master Coder
    Join Date
    Apr 2003
    Location
    in my house
    Posts
    5,211
    Thanks
    39
    Thanked 201 Times in 197 Posts

    will this while loop always do as I think?

    Hi,
    Edit:
    oops. foggy this morning. I should be using qty as the key if only one product can be chosen and if > 1 can be chosen, I need to do it totally differently. This is a non-question. lol


    gotta while loop, checking the $cgi->Vars; coming in from the previous script.

    I want to be sure that the quantity section will always know the product_id from earlier in the if/elsif clause. I wonder what would happen if the incoming vars were in a different order such that quantity was earlier than the product_id.

    Code:
      while ( my ( $key, $value ) = each %vars ){
    
          print qq( k=$key , v=$value<br />);
     
          if ( $key eq 'bid' && $value =~ /^\d+$/){
              $business_id = $value;  
          }
          elsif( $key eq 'pid' && $value =~ /^\d+$/ ){
              $product_id = $value; 	  
          }
          elsif( $key =~ /^\d+$/ && $key == $product_id ){
              $quantity = $value;	  
          }
    	  
      }
    bazz
    Last edited by bazz; 06-07-2011 at 01:14 PM.
    "The day you stop learning is the day you become obsolete"! - my late Dad.

    Why do some people say "I don't know for sure"? If they don't know for sure then, they don't know!
    Useful MySQL resource
    Useful MySQL link


 

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •