Why can't mysql statements receive arrays?
$ SQL = $ empire-> query ("select userid, agentid, username from member where agentid = '". $ user [userid]. "'group by userid ");
While ($ r = $ empire-> fetch ($ SQL)/* get records in the result set row by row to get the Array row */
{
$ Array [] = $ r; // accept the result set
}
Echo'';
Print_r ($ array); // Print the array. the output is an array.
Echo'
';
I want to pass the $ array queried above to the mysql statement below. what should I do. The group by userid is used for classification. the following mysql statement queries the database again, and then classifies the database based on the classification results.
$ Sql2 = $ empire-> query ("select userid, agentid, username from member where agentid in ('. implode ('', array_keys ($ array )). ') group by userid ");
Reply to discussion (solution)
$ Array two-dimensional array
What array_keys ($ array) returns is the subscript of the first dimension of $ array (0, 1, 2, 3 ....)
$ Array two-dimensional array
What array_keys ($ array) returns is the subscript of the first dimension of $ array (0, 1, 2, 3 ....)
How can I write this statement?
There is data in the while loop, but $ array does not have data in the first statement.
What do you want to do?
In this way, the code cannot be hardened.
What do you want to do?
In this way, the code cannot be hardened.
This is the second statement to be connected, so that it can be queried.
Select userid from member where agentid IN (select userid from member where agentid = '$ user [userid] 'group by userid) group by userid
The second query result is classified by the first query. The second query can write statements like this, but how can I write statements for the third query? that's a long statement.
The third query result is classified by the second query
It's done.