MySQL查询从整个列中选择数据而不仅仅是其中的一部分(根据下拉选择排序)。我猜它是由于内爆功能。有办法解决吗? MySQL查询后可能会发生爆炸吗?任何建议都表示赞赏。
$weights = $_POST['pal_numb'];
//var_dump($weights).'br';
//array(1) { [0]=> string(1) "2" }
$weights = "'".implode("','",$_POST['pal_numb'])."'";
$result = mysql_query("SELECT * FROM pl_table WHERE pal_numb in(".$weights.");");
//var_dump($weights).'br';
//array(1) { [0]=> string(1) "2" } string(3) "'2'"
答案 0 :(得分:-1)
$ weights = $ _POST ['pal_numb'];
$ weights =“'”。implode(',',$ _ POST ['pal_numb'])。“'”;
$ result = mysql_query(“SELECT * FROM pl_table WHERE pal_numb in(”。$ weights。“);”);
它将解决您的问题。
答案 1 :(得分:-2)
什么......
$weights = "'" . implode("','", $_POST['pal_num']."'";
你告诉内爆将数组项与','分开。而不仅仅是。请改用
$weights = "'" . implode(',', $_POST['pal_num'] . "'";