Ask SQL statement writing? $ Sql1 is dynamically generated based on user input values: $ ConditionsNumber6; & nbsp; & nbsp; ask about SQL statement writing?
$ Sql1 is dynamically generated based on user input values:
$ ConditionsNumber = 6;
$ ConditionsArray = array ("$ condition1", "$ condition2", "$ condition3", "$ condition4", "$ condition5", "$ condition6 ");
$ SearchSQLArray = array ("where ip = '$ condition1'", "where bianhao = '$ condition2'", "where name = '$ condition3 '", "where user = '$ condition4'", "where bankid =' $ condition5'", "where equimode = '$ condition6 '");
For ($ I = 0; $ I <$ ConditionsNumber; $ I ++)
{
If ($ ConditionsArray [$ I] = "")
$ SearchSQLArray [$ I] = "";
$ HaveWhere = false;
For ($ j = 0; $ j <$ I; $ j ++)
{
$ WherePosition = strpos ($ SearchSQLArray [$ j], "where ");
If ($ wherePosition = "1") & ($ haveWhere = false ))
{
$ SearchSQLArray [$ I] = ereg_replace ("where", "and", $ SearchSQLArray [$ I]);
$ HaveWhere = true;
}
}
};
For ($ I = 0; $ I <$ ConditionsNumber; $ I ++)
$ Sql1 = $ sql1. $ SearchSQLArray [$ I];
$ SQL = "select * from oareport". $ sql1 .";";