Note that there are some explanatory texts on larger screens.

plurals
  1. POvariable scope with if else statements in php
    primarykey
    data
    text
    <p>I have the following code. I am trying to handle two form posts with in the same page. What the code is doing is whenever a user clicks "next14days" button, it display the data for the next 14 days and If the user clicks "prev14days" it should display the data of the previouse 14 days. This for me is not working. </p> <p>for example lets say current date is 2011/01/03 and I hit next14days the current date should be 2011/01/17. This works but when I hit prev14days which should take me back to 2011/01/03, it is going to 2010/12/20 which looks like (2011/01/03 - 14).</p> <p>the page refreshes every time a user hits one of the buttons and anything inside the IF clause is not accessible either way.</p> <pre><code>&lt;?php if(($prevFlag == '' || $nextFlag == '')) { $currentDay = date('Y/m/d'); $SQL4 = "Exec EmployeeVac '" . $currentDay . "'"; $result4 = mssql_query($SQL4,$link1) or die('An error occured: ' . mssql_get_last_message()); } if (isset($_POST['next14submit'])) { $nextFlag = 'yes'; if($prevFlag == 'yes') { $next14 = date('Y/m/d', strtotime($prev14 . "+14 days")); $currentDay = $next14; $SQL4 = "Exec EmployeeVac '" . $currentDay . "'"; $result4 = mssql_query($SQL4,$link1) or die('An error occured: ' . mssql_get_last_message()); } else { $next14 = date('Y/m/d', strtotime($currentDay . "+14 days")); $currentDay = $next14; $SQL4 = "Exec EmployeeVac '" . $currentDay . "'"; $result4 = mssql_query($SQL4,$link1) or die('An error occured: ' . mssql_get_last_message()); } } if (isset($_POST['prev14submit'])) { $prevFlag = 'yes'; echo $nextFlag; if($nextFlag == 'yes') { $prev14 = date('Y/m/d', strtotime($next14 . "-14 days")); $currentDay = $prev14; $SQL4 = "Exec EmployeeVac '" . $currentDay . "'"; $result4 = mssql_query($SQL4,$link1) or die('An error occured: ' . mssql_get_last_message()); } else { $prev14 = date('Y/m/d', strtotime($currentDay . "-14 days")); $currentDay = $prev14; $SQL4 = "Exec EmployeeVac '" . $currentDay . "'"; $result4 = mssql_query($SQL4,$link1) or die('An error occured: ' . mssql_get_last_message()); } } ?&gt; </code></pre>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload