Auto populate for images ?

Hey not sure the right question to ask here . I’m an old school 90s programmer. I’m just getting back into the field. Picking up php java etc…

I’m looking for the right direction and not necessarily the code on how to auto populate images on my site to go to the next page whenever I post a new image. Sorta like forums where if someone posts. The 15th post will automatically go to page 2, and page two will go to page 3 etc.

My entire goal is to just post funny videos , pics on my blog everyday and to have some sort of ease with posting new stuff. I don’t want to have to worry about manually putting in codes everyday. That would be hell .

So again . Hers what I want it to look like on my site

Image 1
Image 2
Image 3
Image 4
Image 5

Previous Page << < 1 2 3 4 5 > >> Next page

A good starting code would be nice but not needed. Php or html . Doesn’t matter .

Appreciate any help !

To make a paginator you need to know how many items you have in total, how many should be displayed on each page, and which page is currently requested.

If you use MySQL.

Get the total number of items
[php]SELECT count(id) FROM image;[/php]

Query for the data you need, use START and LIMIT in the query to define which page you want

Page 1:
[php]SELECT * FROM image START 0 LIMIT 15;[/php]

Page 2, etc…:
[php]SELECT * FROM image START 15 LIMIT 15;[/php]

To display a paginator you have to build your own logic around creating the prev/next and page number buttons/links. It’s basically just iterating over ever page (total/per page) and checking if this is the current page, if not link to images.php?page=current page

[hr]

If you’re getting back into PHP I highly suggest you look into using composer.

Composer is a tool for dependency management in PHP. It allows you to declare the libraries your project depends on and it will manage (install/update) them for you.
https://getcomposer.org/doc/00-intro.md

It makes using 3rd party scripts a lot easier, and you can easily include ie

for generating a paginator (the html part)

Wow, that was very very helpful now I know what it’s called… paginater! Thank you! I haven’t got to the Point of using a composer yetI’m sure I can figure it out from here. I started off program and I was got really good by the time I was 17 and I totally will. Now I am 37 . I’ll

Excuse the typo’s I am voice texting at the moment I start it off when I was 14 I should’ve stuck with it

Sponsor our Newsletter | Privacy Policy | Terms of Service