Jump to content

image slide show


janim

Recommended Posts

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 

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.