PHP code
Public functioninfo () {$where[' OpenID ']=session (' OpenID '));////user session$db= M ("Pay");//primary table name$table= "Pay"; $table 2= "Tupian";//union query table name$page _size= 5;//shows the number of records per pageImport (' ORG. Util.page ');//Import page-out class $count=Count($db, field (' ID '), where ($where), select ());//Total Records $Page=NewPage ($count,$page _size, 5);//To instantiate the total number of incoming records in a paging class $show=$Page->show ();//pagination Display Output $list=$db, Field ("$table. Yin,$table. Time,$table. Status,$table 2. Cover_url,$table 2. title,$table 2. ID ")Join( "$table 2On$table. pid=$table 2. ID ")WHERE ($where),Order ("$table. ID DESC ")Limit ($Page->firstrow. ",".$Page->listrows)Select (); $this->assign (' list ',$list);//Assignment Data Set $this->assign (' page ',$show);//Assignment Paging output $this->display (info);//Output Template }
HTML code
<foreachname= ' list 'Item= ' V '> <Divclass= "Car-list"> <Divclass= "Car-item"> <aclass= "Pro-img"href= "{: U" ("article/index ")}? ID={$v. ID} "><imgclass= "Lazyload"src= "{$v. Cover_url}"alt= "{$v. Title}"style= "width:100px; " /></a> <aclass= "Pro-name"href= "{: U" ("article/index ")}? ID={$v. ID} ">{$v. Title}</a> <aclass= "Pro-name2"href="#">{$v. time|date= "Y-m-d h:i:s", # # #}</a> <Divclass= "Price">Consumer<span>{$v. Yin}</span>Silver Fruit</Div> </Div> </foreach> <Divclass= "pagination">{$page}</Div>
thinkphp3.1 Multi-Table union query code