简体   繁体   中英

How to list photos by category in php

I have two mysql db tables, photos and album, I would like to list photos by album how do i do that ?

CREATE TABLE `album` (
 `id` int(11) unsigned NOT NULL AUTO_INCREMENT,
 `album_name` varchar(95) NOT NULL,
 `album_desc` text NOT NULL,
 PRIMARY KEY (`id`)
);


CREATE TABLE `photos` (
 `id` int(11) unsigned NOT NULL AUTO_INCREMENT,
 `album_id` int(11) NOT NULL,
 `thumb_name` varchar(255) NOT NULL,
 `photo_name` varchar(250) NOT NULL,
 PRIMARY KEY (`id`)
) 

Not sure about the syntax but something like this

 SELECT * FROM photos GROUP BY album_id;

might do the trick.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM