我有一个名为:'objectID' 的 javascript 数组。它填充了几个不同的ID。
Example: objectID = ['465723', '654221, '632876', '102435', '320111', ...]
(includes just 3-6 character numbers, not sure if entered as string or int)
我需要使用“objectID”来查询数据库。
JS
jQuery.ajax({
type: "POST",
url: "filter.php",
data: { objectsArray : objectID },
success: function(result) {
console.log("Object Names:" + result);
}
});
过滤器.php
...
$myArray = $_REQUEST['objectsArray'];
$qstring = "SELECT Name FROM objectlist WHERE ObjectID IN ($myArray)";
$result = mysql_query($qstring);
$results = array();
while ($row = mysql_fetch_assoc($result,MYSQL_ASSOC))
{
$results[] = $row;
}
...
我需要过滤器脚本来返回一个包含对象名称的 javascript 数组:
Example: objectNames = ['Chair', 'Console', 'Lamp', 'Ball', 'TV', ...]
请求数组时出现以下错误:
"mysql_fetch_assoc() expects parameter 1 to be resource, boolean given in"
查询本身似乎有问题。