How to prevent showing some data from an SQL statement

I’m working on a big project for several car companies,developing and taking care of the site.
The problem is that I came on already done site,which btw is written terribly,but aside from that,there are many rules that need to be there in order for the site to work.

The data is stored in DB,and with sql statemets i take that data to the site,do stuff with and eventually show it on the screen.
Mostly,i just convert the mysql resultset to an array and through foreach loop i show them in the table.
And here comes the problem,
every row has its status,and the data is shown by its status (example:if Status is 20,it’s not shown on the screen,but if the status is 1 then that row is shown)except one status.It’s has 2 terms that need to be fullfilled in order for him to show.If the status=8 and DATE_ADD(column1,INTERVAL + 30 day)>CURDATE() it is shown.But that doesn’t work.The row with status 8 is always shown.
How do i prevent him from not showing at all.I have PHP if loop in my script that says if($value[11]==8 and $value[21]>$value[22] ){ $value[11]=50//not shown;},but that also doesn’t work.($value[11]=status $value[21]=DATE_ADD part and $value[22]=CURDATE())

Please help.Thx in advance

SELECT p.VIN ,p.brand,p.make_fin,DATE_FORMAT(p.dat_ser,'%d.%m.%Y') as date,
 p.Partner,p.adress,,p.Tel,p.ID_UNIQ,idm01_statusi_a as status,
 FROM p01_srv as p
 INNER JOIN m01_statusi_a as i
 ON p.idm01_statusi_a=i.idm01_statusi_a
 INNER join p01p03_odgovori as o
 ON p.ID_p01=o.ID_p01

 WHERE orgidf in(SELECT d3.orgid FROM u1_org d1 INNER JOIN table4 ON 
 ( d1.idu1 = d2.idu1 ) INNER JOIN lo360.u1_org d3 ON 
 ( d2.idu2 = d3.idu1 ) where d1.orgid = '*******') 
 and p.idm01_statusi_a in (1 )
 and 1 = 1 and 1 = 1 and 1 = 1 and 1 = 1 and p.IDBRAND in
 ( 1, 2, 3 ) and 1=1 ORDER BY p.dat_ser ASC LIMIT 0, 25

Source: mysql

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.