· 7 years ago · Sep 17, 2018, 12:48 AM
1PHP/MYSQL - User Photos Prev/Next link
2CREATE TABLE IF NOT EXISTS `userphotos` (
3 `photo_id` int(11) NOT NULL auto_increment,
4 `photo_ownerid` int(11) NOT NULL,
5 `photo_ispublic` int(11) NOT NULL,
6 `photo_name` varchar(100) NOT NULL,
7 `photo_caption` varchar(100) NOT NULL,
8 `photo_imagedata` longblob NOT NULL,
9 `album_id` int(11) NOT NULL,
10 PRIMARY KEY (`photo_id`)
11) ENGINE=MyISAM DEFAULT CHARSET=latin1 AUTO_INCREMENT=89 ;
12
13SELECT field1 FROM tablename WHERE id < $currentid ORDER BY id DESC LIMIT 1
14
15SELECT field1 FROM tablename WHERE ID > $currentid ORDER BY id ASC LIMIT 1
16
17SELECT field1 FROM tablename
18WHERE id < $currentId AND photo_ownerid = $ownerId
19ORDER BY id DESC LIMIT 1
20
21SELECT field1 FROM tablename
22WHERE ID > $currentId AND photo_ownerid = $ownerId
23ORDER BY id ASC LIMIT 1