Skip to content
WJunction - Webmaster Forum

Array Condition

Status
Not open for further replies.

ElitePirate

Established Member
136
2009
3
Hi


I have a report.php page where when i click a link, the sql statement will be executed and results will be exported to csv file.


To display the links (for example every monthly report)


[Jan report]
[Feb report]
[Mar report]


i use this code :


$lst_csv = array(
'List - Jan 2013'=>
array(
'table'=>'tbl_jan',
'where'=>"WHERE v_id=12",
'db'=>'main',
'select'=>'name,id'),

'List - Feb 2013'=>
array(
'table'=>'tbl_feb',
'where'=>"WHERE v_id=12",
'db'=>'main',
'select'=>'name,id'),


'List - Mar 2013'=>
array(
'table'=>'tbl_mar',
'where'=>"WHERE v_id=12",
'db'=>'main',
'select'=>'name,id'),


according to the current setup every month i need to add 1 portion for that month. Is there anyway i can add all 12 portion for all 12 months, but the array will display the link only if the current month is <= list month.


Lets say i list down the link for all 12 months in 2013. If i run the php now, it should display link for Jan 2013 only.


Any idea?


Thanks
 

3 comments

You really don't need to use and array to get the right query for the current month. You can use this

Code:
'query'=>
 array(
 'table'=>'tbl_'.strtolower(substr(date('F'),0,3)), 
 'where'=>"WHERE v_id=12",
 'db'=>'main',
 'select'=>'name,id');
 
Status
Not open for further replies.

About the author

E
Established Member · Joined
I'm a Webmaster as well as Sys Admin Coding
136
Messages
3
Reactions
18
Points
Grow your business

Advertise on WJunction

Connect with an established international community of webmasters, hosting providers, developers and online entrepreneurs.

  • Premium & Premium+ Sticky
  • Dedicated section banners
  • Site-wide banner advertising
Explore advertising options
Back
Top Bottom