Forum Moderators: coopster
Code:
<?
$columns = 2;
if (isset($_POST['subm']))$ids=implode(",",$_POST['subm']);
$query = ("SELECT * FROM `tablename` WHERE `ID` IN ($ids)");
$result = mysql_query($query);
@$numrows = mysql_num_rows($result);
for($i = 0; $i < $numrows; $i++) {
$row = mysql_fetch_array($result); {
print "<h1 align='center'>Data for " . $row['firstname'] . " " . $row['lastname'] . "</h1>";
print "<table border=2 width='90%' align='center'>";
if($i % $columns == 0) {
//if there is no remainder, we want to start a new row
print "<TR>\n";
}
print "<TD width='50%'>";
print "<b>" . $row['firstname'] . " " . $row['lastname'] . "</b><br>";
print mysql_field_name($result, 0) . ": " . $row['ID']."<br>";
print mysql_field_name($result, 3) . ": " . $row['address']."<br>";
print mysql_field_name($result, 4) . ": " . $row['city']."<br>";
print mysql_field_name($result, 57) . ": " . $row['physician']."<br>";
print mysql_field_name($result, 58) . ": " . $row['drphone']."<br>";
print mysql_field_name($result, 59) . ": " . $row['draddress']."<br>";
if(($i % $columns) == ($columns - 1) ¦¦ ($i + 1) == $numrows) {
print "</td>";
print "<td>";
}
print mysql_field_name($result, 61) . ": " . $row['meds']."<br>";
if ($row['medications']) print mysql_field_name($result, 62) . ": " . $row['medications']."<br>";
print mysql_field_name($result, 63) . ": " . $row['allergy']."<br>";
if ($row['allergies']) print mysql_field_name($result, 64) . ": " . $row['allergies']."<br>";
print mysql_field_name($result, 65) . ": " . $row['limits']."<br>";
if ($row['limitations']) print mysql_field_name($result, 66) . ": " . $row['limitations']."<br>";
print mysql_field_name($result, 88) . ": " . $row['agreedby']."<br>";
print mysql_field_name($result, 89) . ": " . $row['date']."<br>";
print "</td>";
if(($i % $columns) == ($columns - 1) ¦¦ ($i + 1) == $numrows) {
//if there is a remainder of 1, end the row
//or if there is nothing left in our result set, end the row
print "</TR>\n";
}
} // end for loop
} // end row loop
print "</table>\n";
if (!isset($_POST['subm'])){
print "<p>No entry chosen. Please go back and check the box of the entry you want to print the information for. ";
}
mysql_close();
?>
My long range goal is to take each ID's result and add a CSS page break after it so that all of the selected ID's information can be printed out on a printer, each ID on a separate page.