on-internet
← Community

PHP / MySQL: Display all rows matching specific value in column

Stack Overflow ·

I have a database table which looks something like this: dev_id dev_name cat_id subcat_id 1 Apple iPhone 6 1 1 2 Apple iPhone 6s 1 1 3 Apple iPad Air 1 2 dev_id is the primary key, cat_id is different for each brand (Apple = 1, Samsung = 2 etc.) and subcat_id indicates if the device is either a phone (1) or a tablet (2). I want to echo all the devices of one brand which have subcat_id == 1 assigned to them in one list with the header Smartphones. All the rows where the column subcat_id == 2 need to go in a list below that one with the header Tablets. Both lists need to be sorted by the primary

Comments

Sign in or sign up to comment and upvote.

No comments yet.