janim Posted December 28, 2007 Share Posted December 28, 2007 hi guys how you doing ? i wondering if you have facebook account you will see others images by clicking on the image you will be redirect into the next one ! i have images table like this : ********* id user 1 3 2 2 3 3 4 2 5 8 6 3 7 2 ************* if you noticed the id row is the image id and the (user row) is the user id from another table if i have select statement like this select * form table where user='$curent_user' and id = '$curent_img' how can i make something like facebook slide show ? that means when i click the image it redirect me to the next image for the same user thank you for any little suggestion Quote Link to comment https://forums.phpfreaks.com/topic/83460-image-slide-show/ Share on other sites More sharing options...
GingerRobot Posted December 28, 2007 Share Posted December 28, 2007 Assuming you pass along the the ID of the current image and the user's ID in the URL, something like this would probably be the easiest way: <?php $user_id = $_GET['user_id']; $pic_id = $_GET['pic_id']; $sql = "SELECT * FROM `yourtable` WHERE `user` = $user_id AND $id > $pic_id ORDER BY $pic_id LIMIT 1";//select the next picture with an ID greater than the current one $result = mysql_query($sql) or die(mysql_error()); $num = mysql_num_rows($result); if($num == 0){//if none exist - e.g. this is the last image in the table, select the first image $sql = "SELECT * FROM `yourtable` WHERE `user` = $user_id ORDER BY $pic_id LIMIT 1"; $result = mysql_query($sql) or die(mysql_error()); } $row = mysql_fetch_assoc($sql); //echo out the details you need ?> Obviously you'll need to change it a bit to work with what you have so far, but hopefully that helps. Quote Link to comment https://forums.phpfreaks.com/topic/83460-image-slide-show/#findComment-424900 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.