php - Sql conditional query parameters (include a parameter only when the corresponding form field is filled) -
i'm writing php program using mssql have long query many parameters , quite big database. how solve parameter in query gets included when corresponding form field filled?
example:
select * users userdid='' , status='' , ... lets admin tool seraching users want include and parameter='' sections corresponding form field has been filled.
i check each form field , stich query feel there easier , more elegant way.
brother hope go bellow algorithm
- create globel variable condition.
- check first input value not blank, if not blank put globel variable .
- so on other fileds.
- after input check globel varriable content condtion user submited.
sample example.
var a=""; if(txtuser!="") { = a==""?"username= ".txtuser:"username= ".txtuser; } if(txtcountry!="") { = a==""?"country= ".txtcountry:a." , country= ".txtcountry; } a variable condition
Comments
Post a Comment