AdRock Posted August 31, 2006 Share Posted August 31, 2006 I posted in the php help forum but have found out it is to do with mod rewrite.Here is the code for my image gallery. i have changed the link for mod rewrite which seems to work[code]<?phpdefine ("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 endedif ($count % NUMCOLS != 0) { while ($count++ % NUMCOLS) echo "<td> </td>"; echo "</TR>\n";}echo "</TABLE>";?>[/code]When i click on an image it opens www.jackgodfrey.org.uk/image/1 or whatever the image id is but displays no elarged image. I am sure it's not getting the id from the address bar probably becuase there is nothin gin the address bar called idThis is the code for image.php[code]<?phpinclude_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']."'>";}?>[/code]How can i get the $id variable using $_GET Link to comment Share on other sites More sharing options...
wildteen88 Posted August 31, 2006 Share Posted August 31, 2006 What is the your mod rewrite code you're using. You should still be able to access the id parameter in your code when using mod_rewrite.Your mod rewrite should be something like this:[code]RewriteRule ^images/([0-9]+)$ images?id=$1[/code] Link to comment Share on other sites More sharing options...
Recommended Posts