<?php 
//The code is for selecting all patients records in the database where a particular month and year
//This selects the database and connects to the database
require_once('Connections/Database.php');
mysql_select_db($database_Database, $Database);
if (!$_POST['monapt']| !$_POST['yearapt']) 
{
die('You did not complete all of the required fields,<a href="monthlyrecords.html">Back to previous page </a>');
}
$a=$_POST['monapt'];
$b=$_POST['yearapt'];



$user_result="select * from patients,staff WHERE  patients.dID=staff.dID AND patients.month='$a' AND patients.year='$b' ORDER BY patients.pID ASC";
$stat2=mysql_query($user_result) Or die('Error, query failed,we cant select any records,<a href="monthlyrecords.html">Back to previous page </a>');
$count=mysql_num_rows($stat2);
echo "<pre> $count  record(s) Found</pre>";

echo"<center>";
echo"<table CELLPADDING=10 border=1>";
echo"<tr>";
echo"<td>Patients NO</td>";
echo"<td>Names</td>";
echo"<td>Village</td>";

echo"<td>Department Visited</td>";
echo"<td>Age</td>";
echo"<td>Sex</td>";


echo"<td>Tribe</td>";
echo"<td>symptoms</td>";
echo"<td>Date of Visist</td>";

echo"<td>Weight</td>";
echo"<td>Height</td>";
echo"<td>Temperature</td>";
echo"<td>Blood Pressure</td>";

echo"<td>Doctors Names</td>";



while ($stat3=mysql_fetch_array($stat2))
{
echo"<tr>";
echo"<td>$stat3[pID]</td>";
echo"<td>$stat3[pName] $stat3[pfName]</td>";
echo"<td>$stat3[village]</td>";


echo"<td>$stat3[dept]</td>";
echo"<td>$stat3[age]</td>";
echo"<td>$stat3[sex]</td>";
echo"<td>$stat3[tribe]</td>";
echo"<td>$stat3[symptoms]</td>";
echo"<td>$stat3[day] $stat3[month] $stat3[year]</td>";
echo"<td>$stat3[wgt]</td>";
echo"<td>$stat3[hgt]</td>";
echo"<td>$stat3[temp]</td>";
echo"<td>$stat3[bldp]</td>";

echo"<td>$stat3[dName]  $stat3[fname]</td>";


}
echo"</table>";






?>

this code ignores the month and the year and brings all the data in the database pliz help am stuck and working on the a class project thanks

What is it that you want from the database.

You need to retrieve your results from your $stat3 variable just like you are doing, except in the square brackets the word (key) must be enclosed in quote marks, eg: $stat3

i need to extract data based on the entered month and the year

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.