我正在尝试从我的罪犯数据库的2个表中获取数据,并且当我添加" AND criminal_name =' FIDEL URBINA'"只获取每个犯罪分子的数据。
这是我现在的代码和SQL语句,
$stmt = $mysqli->prepare("SELECT criminal_name, event_location FROM criminal_profile, criminal_locations
WHERE criminal_profile.criminal_id = criminal_locations.criminal_id");
$stmt->execute();
$stmt->bind_result($criminal_name, $event_location); //get data from statement
$stmt->store_result();
if($formaat=='xml'){ //XML
$xml=new SimpleXMLElement('<criminals></criminals>');
while($stmt->fetch()) // zolang er rijen zijn
{
// $criminal_name, Scriminal_pob en $event_location zijn gevuld
//voeg element criminal_pob toe met naam criminal_pob, criminal_name en event_location:
$info = $xml->addChild('criminal');
$item = $info->addChild('criminal_name',$criminal_name);
$item = $info->addChild('event_location',$event_location);
}
header('Content-type: text/xml'); //DIT WERKT NIET? cant send headers after they were sent
// coderen als JSON:
echo $xml->asXML();
}
根据他们拥有的事件位置重复犯罪分子,如下图所示:
http://grabilla.com/05b0e-a271d885-dc45-47ad-a043-c92d832162bd.png
任何人都知道为什么在我添加&#34; AND criminal_name =&#39; FIDEL URBINA&#39;&#34;或者类似的东西?我也试过&#34; AND criminal_name =&#39; F%&#39;&#34;。
答案 0 :(得分:1)
可能是匹配问题,您可以尝试使用templates/<app_name>
操作员而不是like
=