retaining information between pages
Moderator: General Moderators
-
davidklonski
- Forum Contributor
- Posts: 128
- Joined: Mon Mar 22, 2004 4:55 pm
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
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
-
davidklonski
- Forum Contributor
- Posts: 128
- Joined: Mon Mar 22, 2004 4:55 pm
-
davidklonski
- Forum Contributor
- Posts: 128
- Joined: Mon Mar 22, 2004 4:55 pm
Perhaps I didn't read this carefully enough, but...
If you in advance (somehow) know that you are to use images 1,2,3 and 54, put those in an string.
serialize() and base64_encode() the array to get a 'cryptic' string (perhaps not needed but...), that you can forward using the URI ($_GET). Upon recieving this cryptic string, base64_decode() and unserialize() it to get the original string back, then put it in the sql using IN() as part of the where-clause:
The above is untested, needs editing and tweaking, but I was just throwing yet another idea at you. Perhaps something was of use, and good luck.
If you in advance (somehow) know that you are to use images 1,2,3 and 54, put those in an string.
Code: Select all
$images = '1,2,3,54';Code: Select all
Select image from table where id in($string_goes_here)-
davidklonski
- Forum Contributor
- Posts: 128
- Joined: Mon Mar 22, 2004 4:55 pm