Hi,
What I am doing is to search for staff_id from table staff
i would to put a search field to look for staff_id which will past that information on to the another form which will then display the all information from that row.. allowing updates to the fields.....
how would you recommend this?
here is some of my code so you can see what i am doing.....
if(isset($_POST["submit"]))
{
// Info has been submitted, check it:
// Check login, description and description2 are not empty:
# field_validator($field_descr, $field_data, $field_type, $min_length="", $max_length="", $field_required=1) {
field_validator("staff_id", $_POST["staff_id"], "alphanumeric", 4, 15);
field_validator("first_name", $_POST["first_name"], "string", 4, 35);
field_validator("last_name", $_POST["last_name"], "string", 3,35);
field_validator("faulty_id", $_POST["faulty_id"], "number", 3,7);
field_validator("date_started", $_POST["date_started"], "string", 8,12 );
field_validator("group_id", $_POST["group_id"], "number", 1,2);
field_validator("module_id", $_POST["module_id"], "number", 1,7);
field_validator("module_id2", $_POST["module_id2"], "number", 1,7);
field_validator("module_id3", $_POST["module_id3"], "number", 1,7);
// build query:
$query="SELECT staff_id FROM staff WHERE staff_id='".$_POST["staff_id"]."'";
// Run query:
$result=mysql_query($query, $link) or die("MySQL query $query failed. Error if any: ".mysql_error());
if( ($row=mysql_fetch_array($result)) )
{
}
if(empty($messages))
{
global $link;
$query1="update staff SET first_name='$first_name',last_name='$last_name', `faulty_id`='$faulty_id', `date_started`='$date_started', `group_id`='$group_id' WHERE staff_id='$staff_id'";
$query2="update staff SET `module_id`='$module_id',`module_id2`='$module_id2', `module_id3`='$module_id3' WHERE staff_id='$staff_id'";
$result=mysql_query($query1, $link) or die ("died on updating staff details1. error returned if any:" .mysql_error());
$result=mysql_query($query2, $link) or die ("died on updating staff details2. error returned if any:" .mysql_error());
//print "staff details modified to system";
}
else
{
displayErrors($messages);
}
}
$query = "select * from staff where staff_id='$staff_id'";
$result = mysql_query($query);
//will work. then to put all the results in textboxes
// Run query:
$result=mysql_query($query, $link) or die("MySQL query $query failed. Error if anyzzzz: ".mysql_error());
$data = mysql_fetch_array($result);
print "<center>";
print"<H3>Edit details of staff memeber <H3>";
print"<table>";?>
<form action="http://localhost/view_staff.php" method="POST">
<?
print "<input type=\"text\" name=\"staff_id\" value=\"{$data[0]}\"><br />\n";
echo "</tr>";
echo "<input type=\"text\" name=\"first_name\" value=\"{$data[1]}\"><br />\n";
echo "<input type=\"text\" name=\"last_name\" value=\"{$data[2]}\"><br />\n";
echo "<input type=\"text\" name=\"faulty_id\" value=\"{$data[3]}\"><br />\n";
echo "<input type=\"text\" name=\"date_started\" value=\"{$data[4]}\"><br />\n";
echo "<input type=\"text\" name=\"group_id\" value=\"{$data[5]}\"><br />\n";
echo "<input type=\"text\" name=\"module_id\" value=\"{$data[6]}\"><br />\n";
echo "<input type=\"text\" name=\"module_id2\" value=\"{$data[7]}\"><br />\n";
echo "<input type=\"text\" name=\"module_id3\" value=\"{$data[8]}\"><br />\n"; ?>
<input name="submit" type="submit" value="Submit">
</TABLE>
</center>
</form>