一直在努力做这项工作。不知道我哪里出错了。
主页:pkg_list_30d.php
<?php
$conn = new mysqli('host', 'user', 'pwd', 'db');
// check connection
if (mysqli_connect_errno()) {
exit('Connect failed: '. mysqli_connect_error());
}
// check connection
if (mysqli_connect_errno()) {
exit('Connect failed: '. mysqli_connect_error());
}
// SELECT sql query
$sql = "SELECT pkg.*, i.isotope AS pkgisotope
FROM tbl_packagereceipt pkg
INNER JOIN tbl_isotopes i
on
pkg.isotope = i.isoID
GROUP BY pkg.pkgID
ORDER BY `datereceived` DESC
LIMIT 5";
// perform the query and store the result
$result = $conn->query($sql);
// if the $result contains at least one row
if ($result->num_rows > 0) {
// output data of each row from $result
echo '
<table width="568" border="0" cellspacing="1" cellpadding="1">
<tr>
<td width="80" > </td>
<td width="110"> </td>
<td width="108"> </td>
<td width="150"> </td>
<td width="120" > </td>
</tr>
<tr>
<td> </td>
<td><strong>Date</strong></td>
<td><strong>Package #</strong></td>
<td><strong>Isotope</strong></td>
<td> </td>
</tr>
</table>';
$c = false;
while($row = $result->fetch_assoc())
{
echo '<table width="568" border="0" cellspacing="1" cellpadding="1">
<tr style="background:',(($c=!$c)? '#eee' : '#ddd' ),'">
<td width="80"> </td>
<td width="110">'.date('d-M-Y', strtotime($row['datereceived'])).'</td>
<td width="108">'.$row['pkgnumber'].'</td>
<td width="150">'.$row['pkgisotope'].'</td>
<td width="120">' . '<a class="gegevens2"
href="../patientinjection/record_inj_form.php?id=' . $row['pkgID'] . '"> ' .
"Add Patient". '</a>' . '</td>
</tr>
</table>
<br />';
echo include 'pkg_patient.php';
}
}
else {
echo 'All packages returned.';
}
$conn->close();
?>
直接在while()中的表格下面,我希望它显示该结果的患者。我试过做一个页面的包含,但它只显示主页面的顶行(而不是基于查询结果的5或6行)。它显示了它下面的数字1。
pkg_patient.php上的代码是:
<?php
$conn = new mysqli(removed);
// check connection
if (mysqli_connect_errno()) {
exit('Connect failed: '. mysqli_connect_error());
}
// check connection
if (mysqli_connect_errno()) {
exit('Connect failed: '. mysqli_connect_error());
}
// SELECT sql query
$pkgID = (int)$_GET[$id];
$sql = "SELECT pdi.*, radp.radiopharmaceutical AS radp, pkp.initials
FROM tbl_patientdoseinformation pdi
INNER JOIN tbl_isotopes i
ON
pdi.isotope = i.isoID
INNER JOIN tbl_radpharmaceuticals radp
ON pdi.isotope = radp.isotopeID
INNER JOIN tbl_packagepersonnel pkp
ON pdi.adminby = pkp.pkgpersonnelID
WHERE pdi.pkgnumberID='" . $pkgID . "'
GROUP BY pdi.patientdoseID
ORDER BY `datetimestated` DESC";
// perform the query and store the result
$result = $conn->query($sql);
// if the $result contains at least one row
if ($result->num_rows > 0) {
// output data of each row from $result
echo '<table width="1103" border="0" cellspacing="1" cellpadding="1">
<tr>
<td colspan="9"></td>
</tr>
<tr>
<td width="80" > </td>
<td width="110"> </td>
<td width="108"> </td>
<td width="161"> </td>
<td width="84"> </td>
<td width="151"> </td>
<td width="83"> </td>
</tr>
<tr>
<td> </td>
<td><strong>Date</strong></td>
<td><strong>Case No.</strong></td>
<td><strong>Radiopharmaceutical</strong></td>
<td><strong><div align="center">Dose</div></strong></td>
<td><strong><div align="right">State Date/Time</div></strong></td>
<td><strong><div align="right">Initials</div></strong></td>
</tr>
</table>
<br />';
$c = false;
while($row = $result->fetch_assoc())
{
echo '<table width="1103" border="0" cellspacing="1" cellpadding="1">
<tr style="background:',(($c=!$c)? '#eee' : '#ddd' ),'">
<td width="80">' . '<a class="gegevens" href="edit_inj_form.php?id=' .
$row['patientdoseID'] . '"> ' . "Edit". '</a>' . '</td>
<td width="117">'.date('d-M-Y', strtotime($row['datetimestated'])).'</td>
<td width="108">'.$row['patientID'].'</td>
<td width="161">'.$row['radp'].'</td>
<td width="84"><div align="right">'.$row['dose'].' mCi</div></td>
<td width="180"><div align="right">'.date('d-M-Y H:i',
strtotime($row['datetimestated'])).'</div></td>
<td width="83"><div align="right">'.$row['initials'].'</div></td>
</tr>
</table>';
}
}
else {
echo ' ';
}
$conn->close();
?>
答案 0 :(得分:0)
您不需要在pkg_patient.php
中重新运行查询,pkg_list_30d.php
中的所有变量都可以在pkg_patient.php
包含后从{{1}}访问。
答案 1 :(得分:0)
在第68行的pkg_list_30d.php中使用
echo include 'pkg_patient.php';
相反,您应该回显您想要在pkg_patient.php上显示的数据,并在pkg_list_30d.php上使用include pkg_patient.php
包含该数据