Jump to content

Why doesn't this work?


AdRock

Recommended Posts

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]<?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>&nbsp;</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 id

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

?>[/code]

How can i get the $id variable using $_GET
Link to comment
Share on other sites

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

Guest
This topic is now closed to further replies.
×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.