简体   繁体   中英

How can I select all user with same column value (php)

here is my prob. :

I got a users table with a column "music_style" who get value from a select input

example : rock, metal, pop,...

I want to select all other users who have the same "music_style" as me.

Example : If I put "metal" on my profile, i want to see all other profile with metal.

I hope to have been clear, sorry for my bad english :s

Assuming that you are using an sql based dbms, you may use the following sql statement:

 SELECT * FROM `USERSTABLE` WHERE `music_style` = '$myStyle';

$myStyle is the php variable where you are storing the input.

Thanks for your answer, it work perfectly. But it select all user with the same music_style, including me. I tried to correct this but it didn't work .

I tried this :

 $id = $_GET['id']

("SELECT * FROM users WHERE `music_style` = '$myStyle' AND 'id' != '$id' ");

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