updating problem when contain same ID

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
valen53
Forum Contributor
Posts: 137
Joined: Tue Aug 27, 2002 9:29 am

updating problem when contain same ID

Post by valen53 »

i need to select out the people who take OT in the date like 6/6 until 10/6.
below is the code to display the people. So maybe people take OT in 6/6 and 8/6 . so will display 2 time in table. The problem is when i update the status of the people. i can't find out which people was updated. i was use " empid" as unique ID already, but in a query maybe contain a people got 2 record but different date. when only update one of the record, system cannot find out which record was updated.

Code: Select all

<td>'.$empid.'</td><td><div align="center"> 
 <select name="status&#1111;'.$empid.']"></select>
<td>'.$row&#1111;APPLY_DATE].' ~ '.$row&#1111;DATE_TO].'</td>

anyone can help me ? thank a lot......
?>
User avatar
volka
DevNet Evangelist
Posts: 8391
Joined: Tue May 07, 2002 9:48 am
Location: Berlin, ger

Post by volka »

hm, then your id isn't unique anymore, is it? ;)
you might combine empid and the dates to a unique key. You would have to transfer all of those values through your link.
$row[DATE_TO]
please read http://www.php.net/manual/en/language.t ... rray.donts
valen53
Forum Contributor
Posts: 137
Joined: Tue Aug 27, 2002 9:29 am

Post by valen53 »

thank a lot , actually i dunno can put 2 foreach together, tht y i dunno how to do..
thank ur URL

foreach ($_POST['status'] as $status) {
foreach ($status as $status1) {
User avatar
volka
DevNet Evangelist
Posts: 8391
Joined: Tue May 07, 2002 9:48 am
Location: Berlin, ger

Post by volka »

please explain in more detail.
I don't get the point of what you're asking.
valen53
Forum Contributor
Posts: 137
Joined: Tue Aug 27, 2002 9:29 am

Post by valen53 »

Actually i solve the problem already.

Code i used :

Code: Select all

foreach ($_POST&#1111;'status'] as $status) &#123; 
foreach ($status as $status1) &#123;
the value:
name = "status[$emp_id][$apply_date]" -- the unique id
User avatar
volka
DevNet Evangelist
Posts: 8391
Joined: Tue May 07, 2002 9:48 am
Location: Berlin, ger

Post by volka »

i c ;)
Post Reply