my problem is i dunno how to update data for each person. code will like that.....
select * from employee
display the employee list, can be many person ... it contain some of the field can be edit for each person.
after user edit the data for each person then click a update button to update for all of employee. but the problem is that system how to know which record was belong to certain employee? and how to updated it ?
anyone can help me ? thank a lot
update all as a array
Moderator: General Moderators
- twigletmac
- Her Royal Site Adminness
- Posts: 5371
- Joined: Tue Apr 23, 2002 2:21 am
- Location: Essex, UK
yes,the code was something like that...
while(... ) {
<td>'.$row[EMP_ID].'</td>
<td><input name="hours" type="text" value="'.$row[HOURS].'" >
<td><select name="status">
<option value="0" selected>approved</option>
<option value="2">reject</option>
</select></td>
}
so how to know hours textfield are belong to that user ? when update field, how to do it ?
thank ur reply
while(... ) {
<td>'.$row[EMP_ID].'</td>
<td><input name="hours" type="text" value="'.$row[HOURS].'" >
<td><select name="status">
<option value="0" selected>approved</option>
<option value="2">reject</option>
</select></td>
}
so how to know hours textfield are belong to that user ? when update field, how to do it ?
thank ur reply
-
Tubbietoeter
- Forum Contributor
- Posts: 149
- Joined: Fri Mar 14, 2003 2:41 am
- Location: Germany
valen53 wrote:yes,the code was something like that...
while(... ) {
<td>'.$row[EMP_ID].'</td>
<td><input name="hours" type="text" value="'.$row[HOURS].'" >
<td><select name="status">
<option value="0" selected>approved</option>
<option value="2">reject</option>
</select></td>
}
so how to know hours textfield are belong to that user ? when update field, how to do it ?
thank ur reply
try something like
while(... ) {
<td>'.$row[EMP_ID].'</td>
<td><input name="hours" type="text" value="'.$row[HOURS].'" > </td>
<input type="hidden" name="EmpNo" value="$row[EMP_ID]">
<td><select name="status">
<option value="0" selected>approved</option>
<option value="2">reject</option>
</select></td>
}
and remember to close all html tags
if you want to change multiple entries with one request you might also name the elements using arrays/keys.
e.g.
e.g.
Code: Select all
<?php
$dummyEmpIds = array(1,2,7,45,73);
?><?xml version="1.0" encoding="iso-8859-1"?>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
<html>
<head>
<title>test page</title>
</head>
<body>
<pre>
<?php print_r($_POST); ?>
</pre>
<form method="POST" action="http://localhost/test.php">
<p>
<?php
foreach($dummyEmpIds as $EMP_ID)
{
?>
<input type="text" name="hours[<?php echo $EMP_ID; ?>]" /> : #<?php echo $EMP_ID; ?>
<br />
<?php
}
?>
<input type="submit" />
</p>
</form>
</body>
</html><td>'.$row[EMP_ID].'</td>
<input type="text" name="hours[<?php echo $EMP_ID; ?>]" /> : #<?php echo $hours; ?>
<select name="status">
<option value="0" selected>approved</option>
<option value="2">reject</option>
</select>
-------post--------------
<?php print_r($_POST); ?> -- display the record
how we get the each of the value ? i only can get the $hours, but how to get $status and $emp_id ?
foreach ($_POST['hours'] as $hour) {
printf($hour) ;
}
<input type="text" name="hours[<?php echo $EMP_ID; ?>]" /> : #<?php echo $hours; ?>
<select name="status">
<option value="0" selected>approved</option>
<option value="2">reject</option>
</select>
-------post--------------
<?php print_r($_POST); ?> -- display the record
how we get the each of the value ? i only can get the $hours, but how to get $status and $emp_id ?
foreach ($_POST['hours'] as $hour) {
printf($hour) ;
}
Code: Select all
foreach ($_POST['hours'] as $id=>$hour)
echo $id, ': ', $hour;