php - Insert "Selected Users" into another table -


okay having kinds of problems trying figure way script this.

what want have list of people displayed mysql database. once list generated have checkbox next each person.

now here tricky part (at least me), each person checked enter 1 column in table in database. call "rsvp" life of me cannot figure out.

basically need enter user id's checkbox ex these id's checked "1,4,5,6,8". need enter database table "rsvp" , able go , modify same entry checkboxes selected.

i think way on thinking , simple solution.

you should

1) result set database

2) array of selected members

3) iterate of actual dataset , keep generating check boxes, if id matches selected id, generate check box checked.

4) on submitting form, clear old entries , re-insert whatsoever has been selected.

  <form>   <?php   $resultset = getalltheusers here ////   $arrayofselectedusers= getalreadyselectedusers();   //      keep array "id"=>'user name'    while(result not empty){     if(array_key_exists('bar', $foo))         echo "<checkbox value=$result['userid'] checked='checked' name='rsvp' />";    else       echo "<checkbox value=$result['userid']  name='rsvp' />";   }   ?>   <input type='submit' />   </form> 

this should give idea. once form submitted, values, delete existing entries database , re-insert ever has been selected again.


Comments

Popular posts from this blog

c++ - Difference between pre and post decrement in recursive function argument -

php - Nothing but 'run(); ' when browsing to my local project, how do I fix this? -

php - How can I echo out this array? -