AdRock Posted November 11, 2006 Share Posted November 11, 2006 I have decided to split my image gallery into categories but am having trouble rewriting the urls for it.When I click on an image I'm not getting redirected to the proper pagethis is the code for the thumbnails[code]<h2>Image Gallery</h2><?phpdefine ("NUMCOLS",4);include_once("../includes/connection.php");$res = mysql_query("SELECT id,thumb FROM images WHERE cat='jack'");$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='/gallery/jack/image/$id'><img src='/images/gallery/thumbs/$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]this is the code that is supposed to display the image[code]<div style="text-align:center"><? //REMEMBER TO CONNECT TO DATABASE! include_once("includes/connection.php");//**EDIT TO YOUR TABLE NAME, ECT. $t = mysql_query("SELECT * FROM `images`"); if(!$t) die(mysql_error()); $a = mysql_fetch_object($t); $total_items = mysql_num_rows($t); $limit = $_GET['limit']; $cat = $_GET['cat']; $page = $_GET['id']; //set default if: $limit is empty, non numerical, less than 1, greater than 50 if((!$limit) || (is_numeric($limit) == false) || ($limit < 2) || ($limit > 50)) { $limit = 1; //default } //set default if: $page is empty, non numerical, less than zero, greater than total available if((!$page) || (is_numeric($page) == false) || ($page < 0) || ($page > $total_items)) { $page = 1; //default } //calcuate total pages $total_pages = ceil($total_items / $limit); $set_limit = $page * $limit - ($limit); $count = mysql_query("SELECT COUNT(*) FROM images");//query: **EDIT TO YOUR TABLE NAME, ECT. $q = mysql_query("SELECT * FROM images WHERE id = '$page'"); if(!$q) die(mysql_error()); $err = mysql_num_rows($q); if($err == 0) die("No matches met your criteria."); $numofrows = mysql_num_rows($q);//show data matching query: while($code = mysql_fetch_array($q)) { echo "<p><b>".$page."</b> of <b>".$count1 = mysql_result($count,0,0)."</b></p>"; echo "<img src='/images/gallery/large/".$code['image']."'><br/><br/>";} $id = urlencode($id); //makes browser friendly //prev. page: **EDIT LINK PATH** $prev_page = $page - 1; if($prev_page >= 1) { echo("<<<a href=/gallery/$cat/image/$prev_page>Prev. </a>"); } //Display middle pages: **EDIT LINK PATH** echo "<b>".$page."</b>";//next page: **EDIT THIS LINK PATH** $next_page = $page + 1; if($next_page <= $total_pages) { echo("<a href=/gallery/$cat/image/$next_page> Next</a> >>");} //all done ?></div>[/code]and here is my mod rewrite .htaccess[code]Options +FollowSymLinksRewriteEngine onRewriteBase /RewriteRule ^([A-Za-z0-9\-_]+)/?$ index.php?page=$1RewriteRule ^gallery/([A-Za-z0-9\-_]+)/([0-9]+)/?$ index.php?page=$1&id=$2RewriteRule ^gallery/([A-Za-z0-9\-_]+)/([A-Za-z0-9\-_]+)/([0-9]+)/?$ index.php?page=$1&cat=$2&id=$3RewriteRule ^([A-Za-z0-9]+)/([0-9\-_]+)/?$ index.php?page=$1&pagenum=$2RewriteRule ^admin/([A-Za-z0-9\-_]+)/?$ admin/index.php?page=$1 [L][/code]I'm pretty sure the .htaccess is ok becuase it does the rewrite properly. I think it's to do with the way the urls are rewritten n the php. It works when i have a single gallery ??? Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.