我一直在阅读、测试和理解如何创建一个 MySQL 语句来匹配一列与一组值......
这就是我所拥有的...
<form id="form" action="index.php" method="post">
<?
$query = "SELECT Interest FROM Interests";
$result = mysql_query($query);
while ($row = mysql_fetch_assoc($result))
{
echo '<input type="checkbox" name="Interest[]" value="' . $row['Interest'] . '" /> ' . $row['Interest'] . '<br />';
}
?>
<input id="Search" name="Search" type="submit" value="Search" />
</form>
<?
if (isset($_POST['Search']))
{
$InterestMatches = implode(',', $_POST['Interest']);
$query = "SELECT MemberID FROM MemberInterests WHERE Interest IN ( $InterestMatches )";
$result = mysql_query($query) or die(mysql_error());
if (!$result) {
$message = 'Invalid query: ' . mysql_error() . "\n";
$message .= 'Whole query: ' . $query;
die($message);
}
while ($row = mysql_fetch_assoc($result))
{
$ResultingMemberIDs[] += $row['MemberID'];
}
}
?>
我总是得到同样的错误......
Unknown column 'WhateverInterest' in 'where clause'
有人可以告诉我我做错了什么,我需要做些什么来纠正这个问题?