I have this page which has to retrieve the information from a database and display using the list menu object can someone please let me know of how to do it.
The idea is when the name is selected it will retrieve the information relating to that name from the Database to display in the appropriate boxes. The php is given below.
You can scream if i am asking a stupid question. Sorry.
Someone please help.
<!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">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<title>Hr Leave Application Form</title>
<script language="JavaScript" src="ts_picker.js">
//Script by Denis Gritcyuk: tspicker@yahoo.com
//Submitted to JavaScript Kit (http://javascriptkit.com)
//Visit http://javascriptkit.com for this script
</script>
</head>
<body>
<?php
$db_host = "localhost";
$db_user = "xxxx";
$db_pwd = "xxxx";
$db_name = "xxxx";
mysql_connect($db_host, $db_user, $db_pwd);
mysql_select_db($db_name);
?>
<h1> </h1>
<p>
<?php
if (!isset($_POST['submit'])) {
?>
</p>
<form action="" method="post" name="tstest">
<h1>Staff Members Particulars</h1>
<p>Name:<br>
<label>
<select name="name" id="name">
<option>Name 1</option>
<option>Name 2</option>
</select>
</label>
</p>
<p>Staff Number:<br>
<input name="staffnumber" type="text" id="staffnumber">
</p>
<p>Department:<br>
<input type="text" name="department" id="department">
</p>
<p>Present Appoinment: <br>
<input type="text" name="presentappointment" id="presentappointment">
</p>
<p>Period of Present Contract<br />
<input type="Text" name="contract_start" value="">
<a href="javascript:show_calendar('document.tstest.contract_start', document.tstest.contract_start.value);">
<img src="cal.gif" width="16" height="16" border="0" alt="Click Here to Pick up the contract_start"></a>
<input type="Text" name="contract_end" value="">
<a href="javascript:show_calendar('document.tstest.contract_end', document.tstest.contract_end.value);">
<img src="cal.gif" width="16" height="16" border="0" alt="Click Here to Pick up the contract_start"></a><br />
</p>
<p> <input type="submit" name="submit" value="Submit New Item">
<input name="reset" type="reset" id="reset2" value="Clear Form"></p>
</form>
<?php
}
else {
$name = $_POST['name'];
$staffnumber = $_POST['staffnumber'];
$department = $_POST['department'];
$presentappointment = $_POST['presentappointment'];
$contract_start = $_POST['contract_start'];
$contract_end = $_POST['contract_end'];
mysql_query("INSERT INTO `hrformdetailsNew` (name, staffnumber, department, presentappointment, contract_start,contract_end)
VALUES ('$name', '$staffnumber','$department','$presentappointment','$contract_start','$contract_end')");
echo "Successfully Submitted!";}
?>
</body>
</html>