How does php bind database data to a table with eight rows and four columns in a loop? if you know it, please give me some ideas. thank you.

Source: Internet
Author: User
How does php bind database data to a table with eight rows and four columns in a loop? if you know it, let's talk about it, thank you! the function I want to do is to query data from the database (with 31 provinces and municipalities directly under the central government), and then display it in a table with eight rows and four columns. Each province has a check box before it, click it to start a click event and use this province to query some things in php ~~ I don't know what to say. please give me some advice if you know. thank you !!!


Reply to discussion (solution)

The queried data is retrieved cyclically. in the loop, add a variable to determine whether the data has been cyclically repeated for eight times. if the data has been cyclically repeated for eight times, change the output line to the next one. In this way, the table can be typed out.
The click event is not written. What I implement is to use hyperlinks to transmit data to other pages for processing. The principle should be similar. If you use the check box, other programs can receive a check array.
'. "".' Delete '.''.''.'

The queried data is retrieved cyclically. in the loop, add a variable to determine whether the data has been cyclically repeated for eight times. if the data has been cyclically repeated for eight times, change the output line to the next one. In this way, the table can be typed out.
The click event is not written. What I implement is to use hyperlinks to transmit data to other pages for processing. The principle should be similar. If you use the check box, other programs can receive a check array.
'. "".' Delete '.''.''.'


Thank you. I am using the DooPHP framework.

Click province to select all cities?

Click province to select all cities?


Not every province has a check box. a check box binds an event. for example, click the check box before 'Beijing' to POST Beijing to php through ajax, query related data in php in Beijing.

Give me some ideas
$ Count = count ($ arr );
$ TdNum = ($ count + 4-$ count % 4 );
For ($ I = 0; $ I <$ tdNum; $ I ++ ){
If ($ I % 4 = 0) {echo'';}

If ($ I <$ count ){
Check box content
}

If ($ I % 4 = 3) {echo'';}
}

Give me some ideas
$ Count = count ($ arr );
$ TdNum = ($ count + 4-$ count % 4 );
For ($ I = 0; $ I <$ tdNum; $ I ++ ){
If ($ I % 4 = 0) {echo'';}

If ($ I <$ count ){
Check box content
}

If ($ I % 4 = 3) {echo'';}
}


Well, thank you. there is another problem. After splicing the content, put it in $ data ['cmds'], and then $ data ['cmds'] = $ provinces; $ this-> render ('adminn/province ', $ data); submit to the page. you can do this

What is the splicing content?
Does DooPHP support php templates? Write the code and output it directly.
The data passed to the template is in $ this-> data


Give me some ideas
$ Count = count ($ arr );
$ TdNum = ($ count + 4-$ count % 4 );
For ($ I = 0; $ I <$ tdNum; $ I ++ ){
If ($ I % 4 = 0) {echo'';}

If ($ I <$ count ){
Check box content
}

If ($ I % 4 = 3) {echo'';}
}


Well, thank you. there is another problem. After splicing the content, put it in $ data ['cmds'], and then $ data ['cmds'] = $ provinces; $ this-> render ('adminn/province ', $ data); submit to the page. you can do this



You didn't understand what your new question meant,
I have never used DooPHP for the moderator's reminder, so I am not using the framework.
I wonder if DooPHP has encapsulated the ready-made functions.
Maybe you don't have to worry about it. you can flip the document or something.

$ Provinces = '';
$ Count = count ($ allProvinces );
// $ TdNum = ($ count + 4-$ count % 4)
For ($ I = 0; $ I <$ count; $ I ++ ){
If ($ I % 4 = 0) {//,
$ Provinces. ='';
}
$ Provinces. =''. $ AllProvinces [$ I]-> ProvinceName .'';

If ($ I = $ count-1) {// 31
$ Provinces. ='';
}
If ($ I % 4 = 3) {// 3,7, 11,15, 19,23, 27,31
$ Provinces. ='';
}
}
This is what I want to splice.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.