Hi there,
I need some help please. I'm a newbie so please be patient!.
I have created the following database:
CREATE TABLE patientdemo (id INT(4) NOT NULL AUTO_INCREMENT PRIMARY KEY, firstname VARCHAR(30), lastname VARCHAR(30), identitynumber VARCHAR(30)); INSERT INTO patientdemo (firstname, lastname, identitynumber) VALUES ( "Alexa", "McDonald", "1234567890987"), ( "Devie", "Slater", "987654321124" )
I then created an HTML form which has two section. It has a section where users can enter information they want to search for and then a table where I would like information to display in once the search has been preformed.
<html>
<form method="POST" action="search.php">
Search for patient:<br />
<p>
First Name:
<input type="text" id="firstname" name="firstname" /><br />
Last Name:
<input type="text" id="lastname" name="lastname" /><br />
Identity Number:
<input type="text" id="identitynumber" name="identitynumber" /><br />
<p>
<input type="submit" value="Search!" />
</form>
<html>
<head>
<table border cellspacing=0 cellpadding=5>
<caption align=bottom>
</caption>
<tr>
<td colspan=10 rowspan=10></td>
<th colspan=10 align=center>Patient Report</th>
</tr>
<tr>
<th>First Name</th>
<th>Last Name</th>
<th>Identity Number</th>
</tr>
I then wrote a search.php form that handles the code to display the search result.
<?php
// Connect to DB
mysql_connect("localhost","root");
mysql_select_db("patient");
$firstname = mysql_real_escape_string($_POST['firstname']);
$lastname = mysql_real_escape_string ($_POST['lastname']);
$identitynumber = mysql_real_escape_string ($_POST['identitynumber']);
// Perform the fulltext search
$query = "SELECT id, firstname, lastname, identitynumber
FROM patientdemo";
$result = mysql_query($query);
// If results were found, output them
if (mysql_num_rows($result) > 0) {
printf //Display in the following HTML Table
("</form>
<html>
<head>
<table border cellspacing=0 cellpadding=5>
<caption align=bottom>
</caption>
<tr>
<td colspan=10 rowspan=10></td>
<th colspan=10 align=center>Patient Report</th>
</tr>
<tr>
<th>First Name</th>
<th>Last Name</th>
<th>Identity Number</th>
</tr>");
}
else {
printf("No results found");
}
?>
So anyway , the problem is that I want to be able to search for information using the input boxes on the HTML form , and then the info must display in the table (also on the HTML form). How would I go about this.
Once again I'm a newbie so patients please.
Thanking you in advance.