This topic is locked

Initialize A Table

5/22/2013 7:29:01 AM
PHPRunner General questions
P
phpcmk author

Hi,
I currently have a table with a column (year), and I have data for 2012, 2013, 2014.
I need to let user upon login, they will only see current year data which is 2013 and when they use advance search, they can view other year's data.
I tried to input the following code in After table initialized, user when login they can see 2013 data but when they try advance search for other year's data, the data did not appear. Can anyone kindly help on this as I need this to be done urgently? Thanks.
$query->addWhere("year='".date(Y)."'");

P
phpcmk author 5/23/2013

Hi,
I managed to add in some codes, whereby user 1st login, they will see current year data and when they use advance search on other year data, it will reflect correctly the respective year data.



_**Search page: Before process**_

$_SESSION["advsearch"]="yes";
**_After table initialized_**

$date=date("Y");
if($_SESSION["advsearch"]!="yes"){

$query->addWhere("date='".$date."'");

$_SESSION["advsearch"]="no";
}


However, if user navigate across different tabs, it will show all years' records.
Steps to reproduce:

  1. I have created 5 tabs
  2. When users first login, they will select 1 of the 5 tabs in the menu page
  3. by default, they will see only current year (2013) data. Then when they do advance search, they will then be able to see any year (eg. 2014) data based on the filtering they set
  4. However, problem lies when user select other tabs, it will start showing all the years' data. I need to enable that no matter which tabs they select, only show current year data, unless they do an advance search.
    Thanks in advance for the advice.