开发者

Saving image urls

开发者 https://www.devze.com 2023-02-01 16:28 出处:网络
I have a website and I need to add an image gallery using mySQL and PHP. I know that I can开发者_如何学Go save the image urls in a database with an id for each photo, but here\'s the question:

I have a website and I need to add an image gallery using mySQL and PHP. I know that I can开发者_如何学Go save the image urls in a database with an id for each photo, but here's the question: If I have a page with thumbnails of the pictures and I want each thumbnail to link to a page, for example: www.example.com/image/(id number) . How could I do that?


<?php
//$results = example: use sql to select the id and store the results into the $results variable.

foreach($results as $uno) {
    echo '<a href="http://domainname.com/images.php?id=' . $uno['id'] . '">'
}

Each links to images.php, and on that page, the $_GET['id'] pulls the correct image from the database.


The best way to do it is to generate the thumbnail and save (in the same folder or in another one it is the same thing) in the upload process and save the path of the thumbnail along with the path of the full image and you can use any of them as you need.

If you don't generate the thumbnails in the upload process, you will have to generate them every time someone requests the page (it is a huge processing overload) so the performance of your website would be bad.

0

精彩评论

暂无评论...
验证码 换一张
取 消