Update by order of modification please help

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
stivens
Forum Newbie
Posts: 1
Joined: Thu Jun 30, 2011 7:55 pm

Update by order of modification please help

Post 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 :)
User avatar
Christopher
Site Administrator
Posts: 13596
Joined: Wed Aug 25, 2004 7:54 pm
Location: New York, NY, US

Re: Update by order of modification please help

Post 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).
(#10850)
Post Reply