How can I traverse the database to implement a list of multiple images in one row and the paging function !! 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.
Reply to discussion (solution)
Isn't it paging ??
As for the arrangement of your images, that is your layout problem.
Unlike normal paging
This is not implemented solely by databases.
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,
Reply by referencing mylikr:
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!
The layout is simple. There are many methods.
For example, you have 10 images.
Of course, there are two pages.
The first page is eight.
When you output data, a new line is output to the fourth line.
Of course, you can use p + css for control. In short, there are many methods...
The layout is simple. There are many methods.
For example, you have 10 images.
Of course, there are two pages.
The first page is eight.
When you output data, a new line is output to the fourth line.
Of course, you can use p + css for control. In short, there are many methods...
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 )?
$ 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'';
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 "
| 1 | ";}}Echo "
";
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 "";
echo "
";$i = 1;foreach($arr as $value){$str = "
| $value | ";if($i%3==0 || $i==1)echo $i == 1 ? "
".$str : $str."
";elseecho $str;$i++;}echo "
";
$ Value can be changed to the image address by yourself.
$ 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''; // Is to add if the outputWill change the line again .....
}
If ($ I! = 0) echo''; All I want to reference is his algorithm.