0

Info on what I am trying to do. I made a text box where you enter the patient name and then you click on the week from a drop down box and after you click on the look up button it displays the patient name and collects all the data and shows the care provider for that week only. For sample 100 employees in the database 2000 patients. I need it to display the patient and the employees who cared for that person during that week so that person can get paid. I have all the basic done just need help on the result side. Thanks for your help.

My code:

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
    "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">

<head>
  <title></title>
</head>

<body>
<!-- Look Up Patient Name -->
<form action="" name="patient_name" method="get">
<input type="text" name="" />

<!-- Display week -->
<select id="tst" size="1">
</select>

<script type="text/javascript">
/*<![CDATA[*/

function Weeks(year,day,id){
 var srt,ary=[],z0=1,sel=document.getElementById(id),date,months=
['Jan','Feb','Mar','Apr','May','Jun','Jul','Aug','Sep','Oct','Nov','Dec'];
 sel.options.length=0;
 sel.options[0]=new Option('Select Week');
 for (;z0<366+7;z0++){
  srt=new Date(year,0,z0-6,1);
  if (srt.getDay()==day&&srt.getFullYear()<=year){
   date=(day==0?months[srt.getMonth()]:nu(srt.getDate()))
   +'-'+(day==0?nu(srt.getDate()):months[srt.getMonth()])
   +'-'+srt.getFullYear()+'\n';
   sel.options[sel.options.length]=new Option(date,date);
  }
 }
 sel.selectedIndex=0;
}

function nu(nu){
 return nu>9?nu:'0'+nu;
}

Weeks(2014,0,'tst');

/*]]>*/
</script>
<input type="submit" value="Look Up" />
</form>
</body>
</html>


<!-- results -->
<?php
$con=mysqli_connect("localhost","root","","prive_ts");
// Check connection
if (mysqli_connect_errno()) {
  echo "Failed to connect to MySQL: " . mysqli_connect_error();
}

$result = mysqli_query($con,"SELECT * FROM `info`");

echo "<table border='1' width='100%'>
<tr align='left'>
<th>Care Provider</th>
<th>Patient Name</th>
<th>Date of Service</th>
<th>Time In</th>
<th>Time Out</th>
<th>Remarks</th>
</tr>";

while($row = mysqli_fetch_array($result)) {
  echo "<tr>";
  echo "<td>" . $row['care_provider'] . "</td>";
  echo "<td>" . $row['patient_name'] . "</td>";
  echo "<td>" . $row['date_of_service'] . "</td>";
  echo "<td>" . $row['time_in'] . "</td>";
  echo "<td>" . $row['time_out'] . "</td>";
  echo "<td>" . $row['remarks'] . "</td>";
  echo "</tr>";
}

echo "</table>";

mysqli_close($con);
?>
2
  • 1
    Add a where clause to your query? Commented Sep 1, 2014 at 6:46
  • Use date range in where clause Commented Sep 1, 2014 at 7:14

1 Answer 1

1

Your SQL is doing a select all If you want specific results, you need to query for them, for example:

"SELECT * FROM database_name.info WHERE database_name.info.patient_name = '".$s_selected_patient.'"'

I would also recommend escaping your input if you aren't using PDO connections like so:

$s_selected_patient = real_escape_string($s_selected_patient);
Sign up to request clarification or add additional context in comments.

3 Comments

Thanks for the advice but I don't understand how to do the WHERE CLAUSE, date range in where clause, and what Sam posted. New to all this
Your question is far too broad, you're asking for a solution to be wrote, this site is for specific questions. Break down the problem into smaller parts, and if stuck make them questions. Many questions in one question is a bad question.
Thanks for the advice @Sam .. I am having trouble doing the result part. I don't know how to get it all to workout. I need it where when you type a patient name then click the week from the drop down it shows the results of that patient and who seen them in that week. I just can't figure out the coding part.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.