i got some problem on my php codes, i try myself to do a form page and then an action page. i want to retrieve certain row of data by key in the 'id' value on the form pages.
form.html
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<title>Untitled Document</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
</head>
<body><form action="daniel_testing.php" method="post">
<input type="text" name="searchterm">
<input type="submit" value="Search">
</form>
</body>
daniel_testing.php
<html>
<body>
<?php
trim($id);
//$searchtype = $id;
//$searchterm = $id;
$db = mysql_connect("localhost", "root");
mysql_select_db("client1",$db);
// display individual record
if ($id) {
$result = mysql_query("SELECT FROM customer WHERE id ='%$searchterm%'",$db);
$myrow = mysql_fetch_array($result);
printf("Customer ID: %s\n<br>", $myrow["id"]);
printf("Company: %s\n<br>", $myrow["Company"]);
printf("Business Nature: %s\n<br>", $myrow["Business_nature"]);
printf("Contact person: %s\n<br>", $myrow["Contact_person"]);
printf("position: %s\n<br>", $myrow["Position"]);
printf("address: %s\n<br>", $myrow["Address"]);
printf("tel: %s\n<br>", $myrow["Tel"]);
printf("fax: %s\n<br>", $myrow["Fax"]);
printf("handphone: %s\n<br>", $myrow["Handphone"]);
printf("e-mail: %s\n<br>", $myrow["email"]);
printf("website: %s\n<br>", $myrow["Website"]);
printf("birthday: %s\n<br>", $myrow["Birthday"]);
printf("remarks: %s\n<br>", $myrow["remarks"]);
} else {
// show employee list
$result = mysql_query("SELECT FROM customer",$db);
if ($myrow = mysql_fetch_array($result)) {
// display list if there are records to display
do {
printf("<a href=\"%s?id=%s\">%s %s</a><br>\n", $PHP_SELF, $myrow["id"],$myrow["Company"],$myrow["Business_nature"],$myrow["Contact_person"],$myrow["Position"],
$myrow["Address"],$myrow["Tel"],$myrow["Fax"],$myrow["Handphone"],$myrow["email"],$myrow["Website"],$myrow["Birthday"],$myrow["remarks"]);
} while ($myrow = mysql_fetch_array($result));
} else {
// no records to display
echo "Sorry, no records were found!";
}
}
?>
</body>
</html>