i am trying to get data from 2 tables of my criminals database, and its not returning anything when I add a "AND criminal_name = 'FIDEL URBINA'" to get only the data per criminal.
This is my code and SQL statement right now,
$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();
}
which repeats the criminals based on how many event locations they have, as shown in this image:
http://grabilla.com/05b0e-a271d885-dc45-47ad-a043-c92d832162bd.png
Anyone have a idea on why this is not returning data when I add a "AND criminal_name = 'FIDEL URBINA'" or anything like that? I also tried "AND criminal_name = 'F%'".
Could be a matching problem for this you can try with like
operatore instead of =
"SELECT criminal_name, event_location FROM criminal_profile, criminal_locations
WHERE criminal_profile.criminal_id = criminal_locations.criminal_id
AND criminal_name LIKE '%FIDEL URBINA%");
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.