SQL statement into PHP coding

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
asimily
Forum Newbie
Posts: 2
Joined: Wed Nov 20, 2013 12:56 am

SQL statement into PHP coding

Post by asimily »

Hi.. i'm new in PHP.. i really need to learn more in PHP..

but then, i have a task that i must do..but i don't know how to do..
can anybody help me about it..really really need help..thank you very much!

this is the SQL statement..i don't know how to do in PHP coding, to make the result appear..

select value2,value3,
case when (tatr_status='SL' or tatr_status='C') then (count(if(date(tatr_lengkapdate)>=date(tatr_lulus_date)-interval 1 month,tatr_lengkapdate,NULL))) else (count(if(date(tatr_lengkapdate)>=curdate()-interval 1 month,tatr_lengkapdate,NULL))) end as b1,
case when (tatr_status='SL' or tatr_status='C') then (count(if(date(tatr_lengkapdate)>=date(tatr_lulus_date)-interval 2 month and date(tatr_applydate)<date(tatr_lulus_date)-interval 1 month,tatr_lengkapdate,NULL))) else (count(if(date(tatr_lengkapdate)>=curdate()-interval 2 month and date(tatr_lengkapdate)<curdate()-interval 1 month,tatr_lengkapdate,NULL))) end as b2,
case when (tatr_status='SL' or tatr_status='C') then (count(if(date(tatr_lengkapdate)>=date(tatr_lulus_date)-interval 3 month and date(tatr_applydate)<date(tatr_lulus_date)-interval 2 month,tatr_lengkapdate,NULL))) else (count(if(date(tatr_lengkapdate)>=curdate()-interval 3 month and date(tatr_lengkapdate)<curdate()-interval 2 month,tatr_lengkapdate,NULL))) end as b3,
case when (tatr_status='SL' or tatr_status='C') then (count(if(date(tatr_lengkapdate)>=date(tatr_lulus_date)-interval 4 month and date(tatr_applydate)<date(tatr_lulus_date)-interval 3 month,tatr_lengkapdate,NULL))) else (count(if(date(tatr_lengkapdate)>=curdate()-interval 4 month and date(tatr_lengkapdate)<curdate()-interval 3 month,tatr_lengkapdate,NULL))) end as b4,
case when (tatr_status='SL' or tatr_status='C') then (count(if(date(tatr_lengkapdate)<date(tatr_lulus_date)-interval 4 month,tatr_lengkapdate,NULL)))else (count(if(date(tatr_lengkapdate)<curdate()-interval 4 month,tatr_lengkapdate,NULL))) end as more,
count(*) as total
from ta_transaction,ta_fieldconvert where tatr_status=value1 and flags='status' and tatr_lengkapdate>=$P{dari} and tatr_lengkapdate<=$P{hingga} and tatr_status<>'I'
group by value2, value3 order by value3
User avatar
requinix
Spammer :|
Posts: 6617
Joined: Wed Oct 15, 2008 2:35 am
Location: WA, USA

Re: SQL statement into PHP coding

Post by requinix »

Pretty much any PHP + MySQL tutorial will show you how to execute a query and output the results.

Be sure to find one that uses mysqli or PDO extensions and not the mysql extension and mysql_* functions.
asimily
Forum Newbie
Posts: 2
Joined: Wed Nov 20, 2013 12:56 am

Re: SQL statement into PHP coding

Post by asimily »

ooh, ok..

alright, i'll try to find the tutorial first..

thanx yaa.. :)
Post Reply