Forum Moderators: coopster

Message Too Old, No Replies

Issue with the last part of my result page

         

leyva1977

3:56 am on Sep 9, 2014 (gmt 0)

10+ Year Member



I need help on the last part of my coding. I have it where when you look up a name in the search box it pulls up that person's info. I need help on the part where when I type a person's name I can look it up by weeks. So when you type a name in box click on a week and click on the submit button and it will show me all results from that person in that week. The week part is not working right.

Step 1: Type a first and last name
Step 2: Pick a week
Step 3: click on the submit button
Results: Shows the results of patient_name and all the care_providers in that week. IN order care_provider, patient_name, date_of_service, time_in, time_out, and remarks.

I have the search box working to search for patient_name but not the week part.

Table:

CREATE TABLE `info` (
`id` int(11) AUTO_INCREMENT,
`care_provider` varchar(255),
`patient_name` varchar(255),
`date_of_service` date(10), //for the week part
`time_in` time(10),
`time_out` time(10),
`remarks` varchar(255),


The code:

<?php

$con = mysql_connect("localhost","root","");
if (!$con)
{
die('Could not connect: ' . mysql_error());
}

mysql_select_db("prive_ts", $con);

$sql = "SELECT * FROM info";


if (isset($_POST['search_box']) && $_POST['search_box']) {
$search_term = mysql_real_escape_string($_POST['search_box']);
$sql .= " WHERE patient_name = '{$search_term}' ";
}

$query = mysql_query($sql) or die(mysql_error());

?>

<form name="search_form" method="POST" action="results38.php">

Search: <input type="text" name="search_box" value="" />
<input type="week" name="week" value="" />
<input type="submit" name="search" value="Look up Patient ...">

</form>

<table width="70%" cellpadding="5" cellspace="5">

<tr>

<td><strong>Care Provider</strong></td>
<td><strong>Patient Name</strong></td>
<td><strong>Date of Time</strong></td>
<td><strong>Time In</strong></td>
<td><strong>Time Out</strong></td>
<td><strong>Remarks</strong></td>
</tr>

<?php while ($row = mysql_fetch_array($query)) { ?>
<tr>
<td><?php echo $row['care_provider']; ?></td>
<td><?php echo $row['patient_name']; ?></td>
<td><?php echo $row['date_of_service']; ?></td>
<td><?php echo $row['time_in']; ?></td>
<td><?php echo $row['time_out']; ?></td>
<td><?php echo $row['remarks']; ?></td>
</tr>
<?php } ?>

</table>

Dammy

9:36 am on Sep 30, 2014 (gmt 0)

10+ Year Member



Are u sure of ur query?
u cn run it in phpmyadmin to get d result and to knw if the query is valid.