php - Show 3 top results according to date using sql -
I have a website, and I have created a library in it.
The table is: contains: 'book_seender' is the identifier of the sender because any logged user can add books, I send the best sender (which sent a lot of books every week ), So I wanted to show the top 3 head To make a challenge between 3, sender of the week in a PHP file Also assume that you are using MySQL and PDO. book
book_id ,
book_title ,
book_cat ,
book_img ,
book_content ,
active ,
book_date ,
visits ,
book_sender )
champion ---------- book_ id book_chitle book_cat book_img book_content active book_date code spetate (replace the appropriate value of db_name, db_user, and db_password): < < pre>
& lt ;? Php $ db = new PDF ('mysql: host = localhost; d bname = db_name; charset = UTF8', 'db_user', 'db_password'); $ Db- & gt; Set attribute (PDO :: ATTRRAMOD, PDO :: ERRMODE_EXCEPTION); $ Db- & gt; Set attribute (PDO :: ATTR_EMULATE_PREPARES, incorrect); $ Stm = $ db- & gt; Prepare (select "book_sender 'sender id', COUNT (*)` books sent from where the champs where book_date> DATE_ADD (now (), INTERVAL -7 DAY) book_sender LIMIT 0, 3 "by group) ; $ Stm- & gt; Executed (); While receiving ($ line = $ STM-> (PDO: FETCH_ASSOC)) {$ result [] = $ line; } // Step through the results and print? & Gt;
Comments
Post a Comment