How does mysql result and class based on single and double numbers? This is a paging code. Ten records on each page are arranged in reverse chronological order. PHPcode $ SQL = mysql_query (& quot; SELECT * FROMarticleWHEREuid = '000000' ORDERBYdat how does mysql result and class by single and double numbers?
This is a paging code. Ten records on each page are arranged in reverse chronological order.
PHP code
$ SQL = mysql_query ("SELECT * FROM article WHERE uid = '000000' ORDER BY date LIMIT ". $ number. ", 10"); $ num = 1; while ($ row = mysql_fetch_array ($ SQL) {if ($ num = 1) {echo'
';} If ($ num = 5) {echo'
';} // How do I write the code here to calculate the number of classes in a single pair? If ($ num % 5 = 0) {echo'
';}$ Num ++ ;}
The final result I want to output is
HTML code
- 1st result
- 3rd result
- 5th result
- 7th result
- 9th result
- 2nd result
- 4rd result
- 6th result
- 8th result
- 10th result
HTML view
HTML code
ul ul ------------ ------------| 1st result | 2nd result | ------------ ------------| 3rd result | 4th result | ------------ ------------| 5th result | 6th result | ------------ ------------| 7th result | 8th result | ------------ ------------| 9th result | 10th result| ------------ ------------
------ Solution --------------------
PHP code
$ Num = 1; while ($ row = mysql_fetch_array ($ SQL) {if ($ num % 2) {$ left [] ='
'. $ Row ['title'].'';} Else $ right [] ='
'. $ Row ['title'].'';} Echo"
". Implode (" ", $ left ).'; Echo"
". Implode (" ", $ right ).';
------ Solution --------------------
You can also move the pointer.