/    Sign up×
Community /Pin to ProfileBookmark

retaining information between pages

Hello

I am loading images from the database by using the following method:

<img src=”showImage.php?id=1″>

showImage.php knows how to take the id of the imge which is passed to it via $_GET, query the database, extract the appropriate image information (content type, and actual image), and display it.

I have an efficiency problem. If I have a page which has 100 images, then I basically call showImage.php 100 times, which results in 100 queries to the database.

I would like to extract all the data I need (for all the 100 images) in a single query (possible) in the page invoking showImage.php, and pass the information to the showImage.php page somehow. Or even better, place that information in a place that will be accessible to showImage.php
This way showImage will not need to query the database.

I cannot rely on session information because one of the system requirements are that the application must be clustered.

please help

to post a comment
PHP

2 Comments(s)

Copy linkTweet thisAlerts:
@ShrineDesignsJun 01.2004 — find a better way to do the same thing without a database
Copy linkTweet thisAlerts:
@NevermoreJun 01.2004 — How often do the images change, and what exactly does showimage do - is it just a file designed to return the correct information for each image?

If the file information doesn't require processing you could have a file that extracts the image information and saves it to the PHP file in and array so that the images are hardcoded in the script. This could run every hour or every day (or any other frequency) via Cron on Apache, if you're using it. This way you would only query the database every hour/6 hours/day/whatever instead of every time someone requests a page.
×

Success!

Help @davidklonski spread the word by sharing this article on Twitter...

Tweet This
Sign in
Forgot password?
Sign in with TwitchSign in with GithubCreate Account
about: ({
version: 0.1.9 BETA 5.18,
whats_new: community page,
up_next: more Davinci•003 tasks,
coming_soon: events calendar,
social: @webDeveloperHQ
});

legal: ({
terms: of use,
privacy: policy
});
changelog: (
version: 0.1.9,
notes: added community page

version: 0.1.8,
notes: added Davinci•003

version: 0.1.7,
notes: upvote answers to bounties

version: 0.1.6,
notes: article editor refresh
)...
recent_tips: (
tipper: @AriseFacilitySolutions09,
tipped: article
amount: 1000 SATS,

tipper: @Yussuf4331,
tipped: article
amount: 1000 SATS,

tipper: @darkwebsites540,
tipped: article
amount: 10 SATS,
)...