Page 1 of 1

Update by order of modification please help

Posted: Thu Jun 30, 2011 7:57 pm
by stivens
Hello, i'm not sure if this is possible, i can not get the logic or a way to do this using php, i know that pretty much anything can be done with php. heres the problem..

this is the example i have the form with 10 fields.. i have the edit page and external page with events to be applied when the form is open.. in the events page there are functions 1. is before the record is edited 2. after the record is updated. this is the way is working..

field general = general_notes this is a read only field..

field1 = notes1
field2 = notes2
field3 = notes3
field4 = notes4

this is what i have now and is working...

Code: Select all

$general_notes = $value['notes1']." ".$value['notes2']." ".$value['notes3']." ".$value['notes4']; 

$sql = "UPDATE vital SET general_notes = '$general_notes' WHERE case_n = '".$value['case']."'"; 
$res = mysql_query($sql,$conn); 
ok so this is the thing the order right now is notes1, notes2, and so on... sometimes they only edit notes2 so i need that the notes they edit go to the last place for example if they edit only notes 2 this would be the order

Code: Select all

$general_notes = $value['notes1']." ".$value['notes3']." ".$value['notes4']." ".$value['notes2'];  
im not sure how to achieve this, first i need to know which record is actually been edited.. please help.. thanks :)

Re: Update by order of modification please help

Posted: Fri Jul 01, 2011 2:00 am
by Christopher
You need some way to determine which "notes" changed. If you can do that, then you can loop through all the notes and first add all that have not been changed to $general_notes, and then loop a second time an add all that have been changed (this could also be done in one loop).