scarhand Posted January 22, 2009 Share Posted January 22, 2009 i have 2 tables: ass_name (name, city, state) ass_city (name, state) the "city" field comprised of an imploded array ', ' now the "city" fields value is "Abbeville, Abel, Abernant" in ass_name i am trying to check if "Abel" is in "Abbeville, Abel, Abernant" but my query isn't working heres the code: $state = $_GET['state']; $sql = mysql_query("SELECT * FROM ass_city WHERE state='$state' ORDER BY name ASC"); while ($row = mysql_fetch_array($sql)) { $city = $row['name']; $csql = mysql_query("SELECT * FROM ass_name WHERE city IN('$city')"); if (mysql_num_rows($csql) == 0) echo "<input type=\"checkbox\" value=\"$city\"> $city<br />"; else echo "<input type=\"checkbox\" value=\"$city\" disabled> $city (disabled)<br />"; } Link to comment https://forums.phpfreaks.com/topic/141942-mysql-in-array/ Share on other sites More sharing options...
phparray Posted January 22, 2009 Share Posted January 22, 2009 If you are using the MyISAM engine you can add a fulltext index to the city column then use this. SELECT * FROM ass_name MATCH (city) AGAINST ($city) Link to comment https://forums.phpfreaks.com/topic/141942-mysql-in-array/#findComment-743258 Share on other sites More sharing options...
fenway Posted January 27, 2009 Share Posted January 27, 2009 Sounds lke you're looking for an exact match...? Link to comment https://forums.phpfreaks.com/topic/141942-mysql-in-array/#findComment-747511 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.