Hey guys, new here but hopefully you all can help. I'm a complete newbie to php so forgive me in advance! What I'm trying to do is write a report for payments per location of clinics. Example- I have a table that lists all the clinics in my company. At each facility they can take payments which I have a separate table for called payments.
clinics
idclinics
clinic_name
payments
idpayments
patient_id
payment_type
amount
name
What I would like to do is list for each clinic separately all payments for that location. Ex.
EAST
John Smith - $45
Jane Do - $23
Jack Bauer - $87
WEST
Susan Smith - $12
ect..
This is what I have so far.
$sql = "SELECT * FROM payments WHERE payment_date >= '$date1' AND payment_date <= '$date2' AND WHP = '0' AND misc = '0'";
$sql2 = "select clinic_location from clinics";
$result = mysql_query($sql);
$result2 = mysql_query($sql2);
if (mysql_num_rows($result) == 0)
{
echo "No payments found at that location during that time frame.";
echo "$_GET[clinic_location]";
}
while ($row2 = mysql_fetch_assoc($result2))
{
echo "<h3>$row2[clinic_location]</h3>";
echo "<table border='1'>";
echo "<tr><th>Date Rec</th>";
echo "<th> Last Name</th>";
echo "<th>First name</th>";
echo "<th>REF#/CK#</th>";
echo "<th>Payment Type</th>";
echo "<th>Payment</th>";
echo "<th>DOS For payment to be applied</th>";
echo "<th>Notes</th></tr>";
while ($row = mysql_fetch_assoc($result))
{
echo "<td>";
echo $row["payment_date"];
echo "</td><td>";
print $row["PatientLastName"];
echo "</td><td>";
print $row["PatientFirstName"];
echo "</td><td>";
print $row["ref_num"];
echo "</td><td>";
print $row["payment_type"];
echo "</td><td>";
echo "$";
print $row["amount"];
echo "</td><td>";
print $row["dos_for_payment"];
echo "</td><td>";
print $row["notes"];
echo "</td></tr>";