mysql - How can I get my database to update more than once in this "foreach" loop, using PHP? -


this in php web page.

i have link user lands on example: www.example.com/update?attend=1&code[]=4321&code[]=5642&code[]=1842 need update: foreach code attend=1.

my code far:

...database connect information...  $codes = $_get['code']; $invitecode = $_get['invitecode']; foreach ($codes $code) { print $code; ?><br><?php $sql = "update guests set attend='$isattend' invitecode=$code"; }  ...database close , result... 

renders as:

4321 5642 1842 record updated  

when check database last value 1842 set attend=1. prints correct updates one?

does understand doing wrong here?

you can execute each sql in foreach better use in clause.so code hit database 1 time.


Comments

Popular posts from this blog

c - How to retrieve a variable from the Apache configuration inside the module? -

c# - Constructor arguments cannot be passed for interface mocks -

python - malformed header from script index.py Bad header -