Php judgment statement
$ Pubdate = $ dsql-> GetOne ("select pubdate from article where writer = '". $ writer. "'Order by id desc limit 1"); if (time ()-$ pubdate ['pubdate']) <(3600*24) {ShowMsg ("sorry, one member can only send one article per day! ","-1 "," 0 ", 5000); exit ;}
In the above judgment, one member can only submit one document within one day. if you want to modify it, you can submit three documents. what should you do?
Reply to discussion (solution)
$ Pubdate = $ dsql-> GetOne ("select pubdate, writer, count (pubdate) as total from article where writer = '". $ writer. "'and pubdate <". strtotime ("-1 day "). "limit 3 ");
If ($ pubdate ['total']) = 3 ){
ShowMsg ("Sorry, one member can only send one article every day! ","-1 "," 0 ", 5000 );
Exit;
}
Mysql queries the number of articles submitted in a day. if the number is greater than or equal to 3, it cannot be submitted.
$ Pubdate = $ dsql-> GetOne ("select pubdate, writer, count (pubdate) as total from article where writer = '". $ writer. "'and pubdate <". strtotime ("-1 day "). "limit 3 ");
If ($ pubdate ['total']) = 3 ){
ShowMsg ("Sorry, one member can only send one article every day! ","-1 "," 0 ", 5000 );
Exit;
}
Mysql queries the number of articles submitted in a day. if the number is greater than or equal to 3, it cannot be submitted.
Mysql cannot run. Please check.
In addition: if ($ pubdate ['total']) = 3) should be if ($ pubdate ['total']) = 3?
Database field:
Database name (article)
Member Name (writer)
Pubdate)
The original code is changed
$ N = 1; // The number of entries you specify $ pubdate = $ dsql-> GetOne ("select count (*) as cnt from article where FROM_UNIXTIME (pubdate, '% Y % m % d') = DATE_FORMAT (now (),' % Y % m % d') and writer = '". $ writer. "'Order by id desc limit 1"); if ($ pubdate ['pubdate']> $ n) {ShowMsg ("Sorry, one member can only send $ n articles per day! ","-1 "," 0 ", 5000); exit ;}
I still learned from the moderators.