Jump to content


Why doesn't this work?

  • This topic is locked This topic is locked
1 reply to this topic

#1 AdRock

  • Members
  • PipPipPip
  • Advanced Member
  • 911 posts

Posted 31 August 2006 - 12:21 PM

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
define ("NUMCOLS",5);


$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";

    if ($count % NUMCOLS == 0) echo "</TR>\n";  # end row

# end row if not already ended

if ($count % NUMCOLS != 0) {
   while ($count++ % NUMCOLS) echo "<td>&nbsp;</td>";
   echo "</TR>\n";
echo "</TABLE>";
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 id

This is the code for image.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']."'>";


How can i get the $id variable using $_GET
If your topic has been solved, please mark the topic as SOLVED.

This helps others from identifying which topics need help still

#2 wildteen88

  • Staff Alumni
  • Advanced Member
  • 10,482 posts
  • LocationUK, Bournemouth

Posted 31 August 2006 - 03:16 PM

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:
RewriteRule ^images/([0-9]+)$ images?id=$1

0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users