Jump to content

PHP/MySQL n00b question; wrong syntax?


Apenvolkje

Recommended Posts

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

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.

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.