i_terminal_id = input value
SELECT terminal_id,plate_number FROM terminal WHERE terminal_id IN (i_terminal_id);
我i_terminal_id
的示例值是1,2,3,4,但它以nvarchar
有谁能告诉我我的代码有什么问题?它只返回第一个值。
我正在使用MySQLAdmin
这是我的PHP代码:
public function selectTerminals($id){
$form = $this->getUserData();
$form['id'] = $id;
$DAO = $this->getDAO('DAO');
$result=$DAO->query('selectTerminals',$form);
$y = sizeof($result);
// selectTerminals code is
// SELECT terminal_id FROM terminal_sum WHERE userid = i_userid;
$ids = join(',',$result);
$form['terminal_id'] = $ids;
$form['array_count'] = $y;
$DAO = $this->getDAO('DAO');
return $this->status(0,true,'select.success',$DAO- >query('displayTerminals',$form));
$sample = sizeof($ids);
}
答案 0 :(得分:0)
我认为您的PHP代码中存在错误,请尝试以下代码...
<?php
$i_terminal_id = 'input value'; // $i_terminal_id = '1,2,4';
$b = mysql_query(" SELECT terminal_id,plate_number FROM terminal WHERE terminal_id (".$i_terminal_id.")");
while($data= mysql_fetch_array($b))
{
echo '<pre>';print_r($data );echo '</pre>';
}
当你的php变量有字符串值时,然后在mysql查询中以正确的方式使用该变量,单个或双qoute。