dj-kenpo Posted May 2, 2007 Share Posted May 2, 2007 ok, so I have a photo album script. right now I grab the photo by it's table ID. this is messy though as if I grab the second photo in the 4th album, it will really be photo_ID 197, etc. I've thought of a way to just say, get image#2 in album #4 but I'm wondering what you guys think. more and more and more and more sql calls, array if statments etc, it all adds up, does this make sense or seem bloated? //photo album $Count=1; //get image number $pic= $_GET["pic"]; -do an sql call for ALL images in that folder $sql = "SELECT photo_ID FROM photos WHERE Parent_ID=4"; $result = mysql_query($sql); while($row = mysql_fetch_array($result)) { //list out images and count if count = get[image number] then we have the image ID. $photo_ID=$row["photo_ID"]; if ($Count== $pic){ $imaginary_photo_ID = $photo_ID; } $Count++; } it will work, but there's already sql calls for stuff in the header, footer, settings, etc etc etc and it just keeps adding up. can anyone think of eaither a better way of faking the number or a totally different method? storing the fake image number count in the database won't cut it, as photos get deleted or shuffled in order, so that doesn't seem efficient. but maybe it is? maybe doing one intensive edit loop is better than 1000 little ones? cheers! Link to comment https://forums.phpfreaks.com/topic/49714-imaginary-ids/ Share on other sites More sharing options...
dj-kenpo Posted May 3, 2007 Author Share Posted May 3, 2007 anyone? any oppinions? Link to comment https://forums.phpfreaks.com/topic/49714-imaginary-ids/#findComment-244027 Share on other sites More sharing options...
corbin Posted May 3, 2007 Share Posted May 3, 2007 $p = (int) $_GET['pic']; if($p > 0) { $p -= 1; }else { //what to do if it's not a numeric id } $sql = "SELECT photo_ID FROM photos WHERE Parent_ID=4 LIMIT {$p}, 1"; Link to comment https://forums.phpfreaks.com/topic/49714-imaginary-ids/#findComment-244048 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.