Find a PHP code to display images by page

Source: Internet
Author: User
Tags glob
Find a PHP code to display images by page. use PHP to display images in folders by page .. How to write the code .. I can't find it online for a long time.


Reply to discussion (solution)

Obtain the file name cyclically and then output it in html code.

.. Niu, an adult .. I mean none at all

Find a paging class.

I didn't understand what you said ..

Are you not going to display the page or reading the image?

Are you not going to display the page or reading the image?
By page, you can read all the image names to the array. if not many, serialize them to the session, and then allocate the number of pages according to the number of arrays.
Output the content grouped by key on each page.

Are you not going to display the page or reading the image?
By page, you can read all the image names to the array. if not many, serialize them to the session, and then allocate the number of pages according to the number of arrays.
Output the content grouped by key on each page.


Neither can I .. I recently learned PHP by myself. I have been working on a corporate website these two days. other explorations are almost done. I am stuck on the page ..

Girl .. Are you in the class and then calling it?

Girl .. Are you in the class and then calling it?



0.0
This is a function

The usage method is later

$ ImgArray = getDir ('../Images'); // read all the image files in the Images directory and return them to the array imgArray.

// Loop array output value, set the displayed html as needed

Foreach ($ imgArray as $ value ){
Echo'
';
}

 Image
 
  
"; // Output html code $ page =$ _ GET ['Page']; // GET the current page $ max = 3; // set the maximum number of images displayed on each page $ handle = opendir ('. /'); // the current directory while (false! ==( $ File = readdir ($ handle) {// traverse the list ($ filesname, $ kzm) of the directory where the php file is located = explode (". ", $ file); // Obtain the extension if ($ kzm =" gif "or $ kzm =" jpg "or $ kzm =" JPG ") {// File Filter if (! Is_dir ('. /'. $ file) {// folder filter $ array [] = $ file; // Save the qualified file name to the array $ I ++; // record the total number of images }}for ($ j = $ max * $ page; $ j <($ max * $ page + $ max) & $ j <$ I; ++ $ j) {// The number of images displayed in the loop condition control echo"
  
"; // Output image array} $ Previous_page = $ page-1; $ next_page = $ page + 1; if ($ previus_page <0) {echo" previous page "; echo "next page";} else if ($ page <= $ I/$ max) {echo "previous page"; echo "next page";} else {echo "previous page "; echo "next page";} echo" ";?> Girl .. Can I use this one I found? Half understand

The problem should be that it is quite painful to traverse the directory every time by page hh. it doesn't matter if the call is not frequent. if the call is very high, it is more appropriate to read and save it to the database and then call it. Of course, you can also use memcache to store data, but it may not be easy to understand.

It is really hard to understand .. I have about 30 images .. I can barely understand the page I just found .. I don't know how to change the path .. A little depressing .. My PHP is in this path E: \ nanfan \ www \ tmp \ 1 \ 1 and then the image is in this path E: \ nanfan \ www \ tmp \ 1 \ 1 \ product .. ah .. Paging takes my life

Http://www.hh595.com/product.php I was trying to make something like this .. I have been exploring for two or three days .. Ding has not made any progress .. I almost wanted to use HTML to create images one by one .. Then a graph is configured with PHP ..

Amen .. Please help me.

Amen .. Please help me.



I wiped it. Will there be more than 30 pages? How many images do you want to display on one page? Is it HD without code?

Reply to kjkjq520 on the 15th floor:

Amen .. Please help me.


I wiped it. Will there be more than 30 pages? How many images do you want to display on one page? Is it HD without code?


8 images are displayed on one page .. Because I need to set the link .. Click to view the product details
Http://www.hh595.com/product.php girl look at this .. I just want to do that .. Unfortunately, the strength is insufficient.

Amen .. Please help me.

It is wise to store your image path in the database. It is much easier to retrieve data from the database by page.

.. The problem is no .. Girl, Joe .. Sincerely seek education

Paging class. The Internet is too large.
Http://www.google.com.hk/#hl=zh-CN&safe=strict&site=&q=php+%E5%88%86%E9%A1%B5%E7%B1%BB&oq=php+%E5%88%86%E9%A1%B5%E7%B1%BB&aq=f&aqi=&aql=&gs_sm=3&gs_upl=584l3087l0l3323l5l5l0l0l0l0l0l0ll0l0&bav=on.2,or.r_gc.r_pw.,cf.osb&fp=503abead1d20a8e5&biw=1920&bih=976

Your images correspond to different products, so you have to combine them with your database and save them to the database, easy to update. If you do not

Let's do it according to your ideas. there are not many 30 items. I have written a large part of the output directory Image function, and then I will look at the page effect you want, I found that the output cannot be simple, and it must be combined with the database. In this case, either the database is in the warehouse or the human flesh. Instead of reading and displaying the images in the directory, the most correct way is to read the product information in the database and list the product information.

If (strlen ($ upload_file1_name)> 0 & $ ppd-> ID> 0) {$ file_size_max = 6400000; // restrict the maximum file upload capacity (bytes) $ accept_overwrite = true; // allow reading and writing files if (! @ Copy ($ upload_file1, $ store_dir. $ upload_file1_name) // copy the file to the specified directory {echo "failed to copy the file" ;}$ Picture = $ upload_file1; If ($ Picture! = "None") {$ PSize = filesize ($ Picture); // echo $ PSize ."---
"; $ MysqlPicture = addslashes (fread (fopen ($ Picture," r "), $ PSize); $ size = GetImageSize ($ Picture ); $ str = "update MT_pic set picmsg = '$ mysqlPicture', p_w = '$ size [0]', p_h = '$ size [1]' where mtid = '". $ ppd-> ID. "'and edit = 0"; mysql_query ($ str, $ handler); // echo $ str; unlink ($ upload_file1_name );}}

Depends on the number of days .. My dizzy

$ Imgs = array_chunk (glob ('images/*. {gif, GIF, jpg, JPG, png, PNG} ', GLOB_BRACE), 8 );

Then bring $ imgs into the paging class you found.

$ Imgs = array_chunk (glob ('images/*. {gif, GIF, jpg, JPG, png, PNG} ', GLOB_BRACE), 8 );

Then bring $ imgs into the paging class you found.


Learned

If there are not many images, you can directly put the image path into a variable or text file. in js, you can use ajax or go to the image path to be displayed on each page, and then the js operation is performed.

If there are not many images, you can directly put the image path into a variable or text file. in js, you can use ajax or go to the image path to be displayed on each page, and then the js operation is performed.


Big Brother, I don't know much about PHP. I need to do JS .. I will crash.

Reply to reference libo_sina on the 26th floor:
If there are not many images, you can directly put the image path into a variable or text file. in js, you can use ajax or go to the image path to be displayed on each page, and then the js operation is performed.

Big Brother, I don't know much about PHP. I need to do JS .. I will crash.



You won't get rid of the urine database after wearing it...

Basically not. What are you doing!

Lz, you don't even want to build a house...
Let's go back and get the basics done first. someone else gives you a bunch of code and you can say that you can read Tianshu ....

By the way, it means silence. There are a lot of online resources. you can find one and you will be able to use it.

This is the same as the paging of the article title. The key is to write your image path and related information into the database and then display it on pages. this is the easiest way.

 

First save the image name to the database, then read and write it into the array, and then write it again.

Find a paging class.

You and I are just learning PHP, and other people give code, I look like Tianshu ~~~
I suggest you ask the PHP people around you to write a simple page for you first. I will teach you how to learn this at. then I will find a paging class on the internet and do it myself, if you can do this, you will understand what Niu and Qiao Niu told you above.

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.