View Single Post
Old 04-27-2005, 08:39 AM   #1 (permalink)
arch13
Loves my girl in thongs
 
arch13's Avatar
 
Location: North of Mexico, South of Canada
[PHP] Calling an image using variables

I have a page that called brewery.php on my site. It's laid out in total CSS with PHP variable scripts. I call this page into a parent page using the include comand.
Thus, a typical address would be www.arch13.com/index.php?id=main where main is the nested page being called into the parent template index.php.

Now I have a page called brewery.php that containes some new photography and I am looking at new ways of creating gallery's. The current PHP code being used on the page is:
Code:
	 
$id = $_REQUEST['id2'];
if(file_exists($id.".jpg")) {
echo "<img src='$id.jpg'>";
} elseif(file_exists($id.".php")) {
include($id.".php");
} else {
echo "<img src='brewerysplash.jpg'>";
}
Yes it works, but it also creates ugly, ugly, ugly urls. Like http://www.arch13.com/index.php?id=b...ewery/brewery1
Is their a way to simplify this? What I'm looking for is a way to keep the url looking like www.arch13.com/index.php?id=brewery , and then have the id2= hidden, even though it was passed to get the picture it refrences. Perhaps like having brewery.php?id=1 where 1 is the first picture.
Am I making any sense?

The second question I suspect is easier.

the images for brewery.php are named brewery_x.jpg where x is the number of the image in order.
What code would allow id2=1 and call brewery_1.jpg? So that as the id # increased by 1, it just called the next image, assuming the brewery_ part?

Is there a way to go about this that does not require hand coding the image name prefix (brewery_) into the php code, to make such a script usefull in multipule areas?
__________________
Seen on an employer evaluation:

"The wheel is turning but the hamsters dead"
____________________________
Is arch13 really a porn diety ? find out after the film at 11.
-Nanofever
arch13 is offline  
 

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73