Hi All, I am trying to get my sort order system working but I am having problems getting it working properly. What I am trying to do it when the user clicks next it will go to the next record depending on the sort order. Say the user is on an image with the sort order 4 when you click next I want it to get the sort order of 5 and if you click prev it will go to 3 as the image you are current on it sort order 4. Currently the system uses the id but now I want it to use the sort order. There is not set number of images so there is no set number of sort order so its not like i can tell it to get the order using $_GET and using a value from the url. My current code that uses id to sort is below but now i want it to use the field sort_order as each image as a sort_order number. I have tried changing the Order in the queries to sort by sort_order but nothing. I think i need to change the id>$id and id<$id part but im not sure so i posted here. Thanks.
This part of the code gets the information for the current image that is displayed:
<?php
$getimage_query="SELECT id,title,image_url,web_url FROM gallery WHERE id=$id AND area=$area;";
$getimage_result=@mysql_query($getimage_query);
$getimage_data=@mysql_fetch_array($getimage_result)
?>
<div id="view-full-image"><div align="center"><a href="<?php echo $getimage_data['image_url']; ?>"><img src="<?php echo $getimage_data['web_url']; ?>" alt="<?php echo $getimage_data['title']; ?>" border="0" /></a></div>
This part of the code gets the next information for the next link:
</div>
<?php
$getimage_query_next="SELECT id,title,image_url,web_url,sort_order FROM gallery WHERE id>$id AND area=$area ORDER BY id;";
$getimage_result_next=@mysql_query($getimage_query_next);
$getimage_data_next=@mysql_fetch_array($getimage_result_next)
?>
This part of the code gets the data for the Previous link:
<?php
$getimage_query_prev="SELECT id,title,image_url,web_url,sort_order FROM gallery WHERE id<$id AND area=$area ORDER BY id DESC;";
$getimage_result_prev=@mysql_query($getimage_query_prev);
$getimage_data_prev=@mysql_fetch_array($getimage_result_prev)
?>
This part of the code gets the information from the queries above and creates the links for Previous link and next link:
</div>
</div>
<div id="gallery-links">
<div id="prev"><?php if (empty($getimage_data_prev)){ }else{ echo "<a href=\"view-image-".$getimage_data_prev['id']."-".$area.".php\">< Previous</a>"; } ?></div>
<div id="gallery-back"><a href="<?php if ($area=="1"){ echo "gallery.php"; }else{ echo "gallery-art.php"; } ?>">Back to Gallery</a></div>
<div id="next"><?php if (empty($getimage_data_next)){ }else{ echo "<a href=\"view-image-".$getimage_data_next['id']."-".$area.".php\">Next ></a>"; } ?></div>
</div>
Any help would be great thanks.