I have been making a simple image gallery but have come across a problem displaying the enlarged image
When i click on a thumbnail (gallery.php)I am directed to a page called image.php where the chosen image is supposed to enlarge but it displays nothing and I am convinced it is to do with the $_GET['id']
If i use an unwritten url such as index.php?page=image&id=1 it will display but if i use a reritten url such as image/1 it doesn't display. I am sure it can't $_GET the id from the address bar becuase it doesn't know what id is. All there is, is a number which is the id of the image.
Here is the code for the image gallery
<?php
define ("NUMCOLS",5);
include_once("includes/connection.php");
$res = mysql_query("SELECT id,thumb FROM images");
$count = 0;
echo "<TABLE border=0 id='gallery'>";
while (list($id,$thumb) = mysql_fetch_row($res)) {
if ($count % NUMCOLS == 0) echo "<TR>\n"; # new row
echo "<TD><a href='/image/$id'><img src='/gallery/$thumb' style='border:none'></a></TD>\n";
$count++;
if ($count % NUMCOLS == 0) echo "</TR>\n"; # end row
}
# end row if not already ended
if ($count % NUMCOLS != 0) {
while ($count++ % NUMCOLS) echo "<td> </td>";
echo "</TR>\n";
}
echo "</TABLE>";
?>
Here is the code which is supoposed to display the enlarged image
<?php
include_once("includes/connection.php");
$id = $_GET['id'];
$query = "SELECT * FROM images WHERE id = '$id'";
$result = mysql_query($query) or die(mysql_error());
while ($row = mysql_fetch_array($result)) {
echo "<img src='/gallery/".$row['image']."'>";
}
?>
and here is the mod rewrite but i don't think that makes any difference
Options +FollowSymLinks
RewriteEngine on
RewriteBase /
RewriteRule ^([A-Za-z0-9]+)/?$ index.php?page=$1 [L]
RewriteRule ^([A-Za-z0-9]+)/([0-9]+)/?$ index.php?page=$1&pagenum=$2 [L]
RewriteRule ^([A-Za-z0-9]+)/([0-9]+)/?$ index.php?page=$1&id=$2 [L]
RewriteRule ^admin/([A-Za-z0-9]+)/?$ admin/index.php?page=$1 [L]