Jump to content

Recommended Posts

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

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.