Results 1 to 6 of 6

Thread: Need help please with conditional statements

  1. #1
    Join Date
    Sep 2007
    Location
    Maui
    Posts
    642
    Thanks
    284
    Thanked 15 Times in 15 Posts

    Default Need help please with conditional statements

    I was up all night trying in vain to get my form to load into a table. I can't for the life of me figure out what is wrong with this code. The variable $rectype definitely has the value of 2 and $recweekly is set, yet none of the code seems to be executing within the if. I don't know what else to try. It doesn't even show the value of $days. I have trouble understanding the php manual, but I did make a valiant effort... I guess I was born without the php gene. Please help. Thanks.

    Code:
      if (isset($_POST['rectype']) && $_POST['rectype'] == '2' ) {		
    		
    		if (isset($_POST['recweekly'])) {
    			$days = ( (in_array(0, $_POST['recweekly'])) ? 'y' : 'n' )
    						. ( (in_array(1, $_POST['recweekly'])) ? 'y' : 'n' )
    						. ( (in_array(2, $_POST['recweekly'])) ? 'y' : 'n' )
    						. ( (in_array(3, $_POST['recweekly'])) ? 'y' : 'n' )
    						. ( (in_array(4, $_POST['recweekly'])) ? 'y' : 'n' )
    						. ( (in_array(5, $_POST['recweekly'])) ? 'y' : 'n' )
    						. ( (in_array(6, $_POST['recweekly'])) ? 'y' : 'n' );
    		} else {
    			$days = "nnnnnnn";
    	}
    		$wkofmon = "nnnnn";
    		$freq = ( $_POST['week_freq'] ? $_POST['week_freq'] : 1 );
    		
    		echo $days; echo $wkofmon; exit;
      } //end weekly

  2. #2
    Join Date
    Mar 2006
    Location
    Illinois, USA
    Posts
    12,164
    Thanks
    265
    Thanked 690 Times in 678 Posts

    Default

    Run this before the if; report results:
    echo $_POST['rectype'].'|'.$_POST['recweekly'];
    Daniel - Freelance Web Design | <?php?> | <html>| español | Deutsch | italiano | português | català | un peu de français | some knowledge of several other languages: I can sometimes help translate here on DD | Linguistics Forum

  3. #3
    Join Date
    Sep 2007
    Location
    Maui
    Posts
    642
    Thanks
    284
    Thanked 15 Times in 15 Posts

    Default

    It just kept going straight to the result page, so I disabled that and got a totally blank page. With debug on, here are some of the variables listed:

    [daily-freq] => 1
    [rectype] => 2
    [recweekly] => Array
    (
    [0] => 5
    )

    [week_freq] => 1
    [wkofmon] => 1
    [monthly_dow] => 0
    [moday_freq] => 1
    [dayofmon] => 27
    [monthly-months] => 1
    [enddate] => 2008-08-27

    It is loading the event table but not the recur table. Even though it has the values, it seems to be ignoring the if statements. I don't get it. Thanks for helping.

  4. #4
    Join Date
    Mar 2006
    Location
    Illinois, USA
    Posts
    12,164
    Thanks
    265
    Thanked 690 Times in 678 Posts

    Default

    Odd.

    Run this:
    PHP Code:
    <?php
    if (!(isset($_POST['rectype']) && $_POST['rectype'] == '2' )) {  die('This is FALSE'); }
    ?>
    Daniel - Freelance Web Design | <?php?> | <html>| español | Deutsch | italiano | português | català | un peu de français | some knowledge of several other languages: I can sometimes help translate here on DD | Linguistics Forum

  5. The Following User Says Thank You to djr33 For This Useful Post:

    kuau (07-29-2008)

  6. #5
    Join Date
    Sep 2007
    Location
    Maui
    Posts
    642
    Thanks
    284
    Thanked 15 Times in 15 Posts

    Default

    Got a blank page again. The whole section of code is inside this.. could it have something to do with it?

    Code:
    if (isset($_POST['submit']) && $_POST['submit'] == ' SUBMIT EVENT ') {
    When there are several options for a user to choose from, what is the best way to determine what they chose? Should you ask them to click on something to indicate their choice (eg. Does this event recur?) and disble the fields unless they click it, or just check to see if any of the recur types are filled in? The way I'm doing it obviously doesn't work. Thanks.

  7. #6
    Join Date
    Mar 2006
    Location
    Illinois, USA
    Posts
    12,164
    Thanks
    265
    Thanked 690 Times in 678 Posts

    Default

    Well, the post variables on your page are global in scope. That means they don't need to be inside anything. You should run ONLY that code above to see if, based on the post data submitted, those return false. If they are true, then, yes, it is probably something else on the page, like that if statement you just mentioned.

    The syntax of the statement looks ok, though I can't tell you if ' SUBMIT EVENT ' is correct.

    The other thing you can do is use <?php print_r($_POST); ?> and just see what you have submitted.
    Daniel - Freelance Web Design | <?php?> | <html>| español | Deutsch | italiano | português | català | un peu de français | some knowledge of several other languages: I can sometimes help translate here on DD | Linguistics Forum

  8. The Following User Says Thank You to djr33 For This Useful Post:

    kuau (07-29-2008)

Bookmarks

Posting Permissions

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