好的,我已经编辑了我的邮件,并在回复中提供了第二个查询的代码。我还包括了对结果的期望的屏幕截图;这是:
这可能是你的建议吗?
<?php
//The first working MySQLi SELECT statement is here .....
}
/* Close the statement */
$stmt->close();
}
else {
/* Error */
printf("Prepared Statement Error: %s\n", $mysqli->error);
}
if ($stmt = $mysqli->prepare("SELECT PersonID,ImagePath FROM t_persons
NATURAL JOIN t_incidents
NATURAL JOIN t_incident_persons
WHERE t_persons.PersonID = '$PersonID' AND t_incident_persons.IncidentID = t_incident.IncidentID")) {
/* Execute the prepared Statement */
$stmt->execute();
/* Bind results to variables */
$stmt->bind_result($PersonID,$ImagePath);
/* fetch values */
while ($rows = $stmt->fetch()) {
// display records in a table
<?php echo '<img src="./Persons_Images/'.$ImagePath.'" width="300" height="400" border="1" />'; ?>
}
}
/* close our connection */
$mysqli->close();
?>
预期结果应为:
答案 0 :(得分:0)
为表格执行自然连接
select ('coulmns in need') from t_persons natural join t_incidents natural join t_incident_persons;