我想傳遞一個包含衆多的用戶名,用逗號分隔的字符串,創建一個動態查詢,並想通過它來查詢瞭如何使用「IN」在MySQL
$name_list='kesong,nicholas,jane'; //this value would change
$select_occupy=mysql_query("SELECT * FROM user_data WHERE `username` IN('$name_list') ORDER BY `occupy_date` ");// i think this would just search for a username which is 'kesong,nicholas,jane', instead searching them seperately
echo mysql_num_rows($select_occupy); //would echo 0
我知道它只是當你指定一個像IN(「$名稱1」,「$名2」,「$ NAME3」),但我需要一個動態的
不要使用mysql_ *功能 - 它們已被棄用 – user4035
依賴於原始名單,數組的格式和源最簡單的,你可以使用implode – 2014-03-04 01:29:32
你是什麼意思?@Dagon –