php - Get Previous and Next records in MYSQL with non-numeric ID -


i trying develop small photo cataloging , storage system in php / mysql. database structured follows:

create table `photos` (   `picid` varchar(36) not null,   `uploaded` varchar(10) not null,   `picdesc` text not null,   `views` bigint(20) not null,   `albumid` varchar(36) not null comment 'fkey albums',   `uploadedby` varchar(50) not null comment 'fkey users',   `exif` longtext not null,   `album_protected` tinyint(1) not null default '0',   primary key  (`picid`) ) engine=myisam default charset=utf8; 

the picid field guid used primary key.

i need creating sql query return record previous passed in picid , record next too. think need use 2 queries, perhaps can tell me otherwise. records ordered uploaded unix timestamp value.

hope can help! please tell me if require more info!

give auto_increment integer field primary key, , change picid unique. unique, indexed , can still used lookups. if want sequence in rows, need auto_increment field , have primary keys in mysql.

 create table `photos` (  `rowid` int auto_increment primary key,  `picid` varchar(36) not null unique,  `uploaded` varchar(10) not null,  `picdesc` text not null,  `views` bigint(20) not null,  `albumid` varchar(36) not null comment 'fkey albums',  `uploadedby` varchar(50) not null comment 'fkey users',  `exif` longtext not null,  `album_protected` tinyint(1) not null default '0'  ) engine=myisam default charset=utf8; 

Comments

Popular posts from this blog

Unable to remove the www from url on https using .htaccess -