Copy codeThe Code is as follows:
<? Php
$ Dsn = "mysql: host = localhost; dbname = group ";
$ Db = new PDO ($ dsn, 'root ','');
$ Db-> exec ('set names utf8 ');
$ SQL = "select conf_id from 'group' group by conf_id ";
// $ Pre = $ db-> prepare ($ SQL );
// $ Result_arr = array ();
$ Pre = $ db-> query ($ SQL );
$ Result_arr = $ pre-> fetchAll (PDO: FETCH_ASSOC );
// Print_r ($ result_arr );
Foreach ($ result_arr as $ v)
{
Echo $ v [conf_id]. "<br> ";
$ Vv = $ v [conf_id];
$ Re = array ();
$ Sql1 = "select * from 'group' where conf_id = '$ v [conf_id] 'order by time ";
$ Sql2 = "select * from 'group' where conf_id = '$ v [conf_id] 'order by time DESC ";
$ Rs1 = $ db-> query ($ sql1 );
$ Rs2 = $ db-> query ($ sql2 );
$ Re1 [$ vv] = $ rs1-> fetchAll (PDO: FETCH_ASSOC );
$ Re2 [$ vv] = $ rs2-> fetchAll (PDO: FETCH_ASSOC );
Print_r ($ re1 [$ vv] [0]);
Print_r ($ re2 [$ vv] [0]);
}