How to traverse the database to implement a list of multiple images in one row and paging?-php Tutorial

Source: Internet
Author: User
Urgent !! High score for advice !! How can I achieve a list of multiple images in one row by traversing the database and the paging function is urgent !! You can traverse the database to implement a list of multiple images in one row and the paging function. it is best to share the instance code to: Urgent !! High score for advice !! How can I traverse the database to implement a list of multiple images in one row and the paging function?
Urgent !! You can traverse the database to implement a list of multiple images in one row and the paging function. it is best to have the instance code.

Share:


------ Solution --------------------
Isn't it paging ??

As for the arrangement of your images, that is your layout problem.

Unlike normal paging
------ Solution --------------------
Reference:
Reference:
Urgent !! You can traverse the database to implement a list of multiple images in one row and the paging function. it is best to have the instance code.

Ask !! How to layout,

Isn't layout a problem with CSS?










So far!

------ Solution --------------------
$ Num = 4; // number of sheets per line
$ I = 0; // counter
While ($ row = mysql_fetch_assoc ($ rs )){
If ($ I = 0) echo'';
Echo''. $ Row ['image field name'].'';
$ I = ($ I + 1) % $ num;
If ($ I = 0) echo'';
}
If ($ I! = 0) echo'';

------ Solution --------------------
Reference:
I use php to traverse the database to get the data output in the image table, but I do the traversal, only need to make an image box, and then output all the images through the loop (I have done it before, however, the output is a row of images. I am wondering how to arrange the output Images From left to right (for example, to put four images in one row )?

Your question falls into the category of the front-end artist. since you asked, I will talk to you briefly. it is actually very simple, but it is just a matter of control during the cycle.
I will give two examples. The first is table, and the second is p layout.

Echo "











";For($i=0;$i<10;$i++){IF($i % 3==0){IF($i>0){Echo " ";}Else{Echo " ";}}Else{Echo " ";}}Echo "
1
";


Below is the second method
This method requires css control.
# Box p {float: left; width: 33% ;}

Echo "

";
For($i=0;$i<10;$i++){
Echo "

1

";
}
Echo "

";


------ Solution --------------------

Echo"















";$ I = 1;Foreach ($ arr as $ value){$ Str =" ";If ($ I % 3 = 0------ Solution --------------------$ I = 1)Echo $ I = 1? " ". $ Str: $ str ." ";ElseEcho $ str;$ I ++;}Echo"
$ Value
";

$ Value can be changed to the image address by yourself.

Related Article

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.