Apenvolkje Posted April 15, 2008 Share Posted April 15, 2008 Hello! What's wrong with my query? The part till the AND works, but I only want to add +1 to 'volgorde' where the 'afdeling' matches the 'afdeling' of the form I am submitting. $result=db_query(sprintf("UPDATE portfolio SET volgorde = volgorde +1 WHERE volgorde >= '%s',$form['volgorde'] AND `afdeling` = $form['afdeling'])); I think it must be a syntax error. The basic function of the code should be: (when submitting a form with values 'volgorde' and 'afdeling') +1 all 'volgordes' of existing entries in the database if 'afdeling' of the new entry matches 'afdeling' of existing entries. Thanks in advance, Apenvolkje Link to comment https://forums.phpfreaks.com/topic/101171-phpmysql-n00b-question-wrong-syntax/ Share on other sites More sharing options...
r-it Posted April 15, 2008 Share Posted April 15, 2008 please clarify what ,$form['volgorde'] is doing or can you make it into English as ek verstaan 'n bietjie van wat jy se Link to comment https://forums.phpfreaks.com/topic/101171-phpmysql-n00b-question-wrong-syntax/#findComment-517569 Share on other sites More sharing options...
Apenvolkje Posted April 15, 2008 Author Share Posted April 15, 2008 I have a form that's being filled in to add an entry to the database. Before the form gets submitted the code has to update all integers "volgorde" (translate: order) that already exist in the database and are the SAME or higher than the "volgorde" that is entered in the form. (That already worked with the first part of the code, just before AND) Then the code also must only do that for all entries that share the same "afdeling" (translate: department) because every department can has it's own unique "volgorde" (multiple "volgorde"s can exist simultanously having the same values, as long as they are in different departments. ========= summary ============ Code SHOULD do: [just before submittingform with entry "volgorde"] update existing database entries at "volgorde" and give +1 if they are the same or higher than "volgorde" in the form AND have the same "afdeling" as the form to be submitted has. Link to comment https://forums.phpfreaks.com/topic/101171-phpmysql-n00b-question-wrong-syntax/#findComment-517589 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.