0

I want my form to update values in my MySQL database, how would I go on doing that with multiple values ? I think I understand how it works with single values, but not with multiple. Any help is appreciated, this is how far I got:

$queue = "UPDATE hurlumhei SET (barn, voksenuke, voksenhelg, klippekort, klippekortmega, parkering) VALUES ($barn, $voksenuke, $voksenhelg, $klippekort, $klippekortmega, $parkering)";
  • 1
    Dont forget proper escaping and the WHERE condition or you end up changing everything and having security issues – Philipp Aug 21 '13 at 22:21

1 Answers1

3

Like this:

UPDATE hurlumhei 
   SET barn = $barn
      ,voksenuke = $voksenuke
      ,voksenhelg = $voksenhelg
      ,klippekort = $klippekort
      ,klippekortmega = $klippekortmega
      ,parkering = $parkering

Since you are using PHP, you probably want to look into prepared statements to send in values.

bhamby
  • 15,112
  • 1
  • 45
  • 66
  • Thanks a lot @bhamby that worked perfectly fine, and I will look into prepared statements, I just got into php programming. – user2580094 Aug 21 '13 at 22:23
  • Great! Using prepared statements will help [prevent SQL Injection](http://stackoverflow.com/questions/60174/how-can-i-prevent-sql-injection-in-php?rq=1). Also, if the answer worked for you, then please "accept" the answer using the green check mark to the left of the question. – bhamby Aug 21 '13 at 22:27