script changes

Discussion in 'Programming' started by cavendano, Sep 11, 2007.

  1. #1
    i have a script that currently runs in a one track mindset....currently the user makes a selection from four options but the outcome is identical regardless of the selection. what i need to have changed is that if a user selects option 1 the end variable will be different.
     
    cavendano, Sep 11, 2007 IP
  2. ErectADirectory

    ErectADirectory Guest

    Messages:
    656
    Likes Received:
    65
    Best Answers:
    0
    Trophy Points:
    0
    As Seller:
    100% - 0
    As Buyer:
    100% - 0
    #2
    Very general question, perhaps more details will get you better results. But since you are mentioning user selections, see if this fits ...

    
    
    if ($_POST['selection'] == 'AnswerA') {
      echo 'resulting page for Answer A' ;
    } 
    elseif ($_POST['selection'] == 'AnswerB') {
      echo 'resulting page for Answer B' ;
    } 
    elseif ($_POST['selection'] == 'AnswerC') {
      echo 'resulting page for Answer C' ;
    } 
    else {
      echo 'resulting page for Answer D' ;
    }
    
    
    PHP:
     
    ErectADirectory, Sep 11, 2007 IP
  3. papa_face

    papa_face Notable Member

    Messages:
    2,237
    Likes Received:
    67
    Best Answers:
    1
    Trophy Points:
    285
    As Seller:
    100% - 0
    As Buyer:
    0.0% - 0
    #3
    I have sent you a PM regarding this work.
    ^^ I think this is a much more efficient way to do it, but it produces the same affect:
    
    switch ($_POST['selection'])
     {
       case "AnswerA":
       echo 'resulting page for Answer A' ;
       break;
       case "AnswerB":
       echo 'resulting page for Answer B' ;
       break;
       case "AnswerC":
       echo 'resulting page for Answer C' ;
       break;
       case "AnswerD":
       echo 'resulting page for Answer D' ;
       break;
       default:
       echo 'you did not provide an answer';
     }
    PHP:
     
    papa_face, Sep 11, 2007 IP