html - PHP MySQL Options using JOIN -


i have table...

table: forums

for_id  for_name       for_des           for_mem   1      forum 1    description 1     mem1@email.com, mem2@email.com    2      forum 2    description 2       null   3      forum 3    description 3     mem1@email.com 

then have table: members

mem_id mem_name     mem_email ...    1     jane    mem1@email.com    2     jack    mem2@email.com    3     smith   mem3@email.com 

i trying create html options list. multi select list display columns in members , select in forums when editing information.

example: editing for_id = 1 should display users , select users in for_id=1's for_mem

currently using:

<? $data = explode(',',$row[for_mem]); ?> <div class="col-md-9">     <select name="for_mem" id="" multiple class="form-control">         <?php foreach($data $key => $value){?>         <option value="<?php echo $value; ?>"><?php echo $value; ?></option>         <?php } ?>     </select> </div> 

but displays users in for_mem forum, not users them select new ones add. also, email. there way display name?

please help.

this query can solve partly & join both union. first part members exist in forums , second part members not exist forums. have added field "checked" 1 first part , 0 second part used identified users checked when display.

select for_id, for_name, for_mem, mem_name, mem_email, 1 checked forums, members locate(mem_email, for_mem) > 0 union select for_id, for_name, for_mem, mem_name, mem_email, 0 checked forums, members locate(mem_email, for_mem) = 0; 

may there syntactically mistake haven't tested because of data unavailable. can use group or group concat more. advice run on mysql prompt first , see result , modify need.


Comments

Popular posts from this blog

OpenCV OpenCL: Convert Mat to Bitmap in JNI Layer for Android -

android - org.xmlpull.v1.XmlPullParserException: expected: START_TAG {http://schemas.xmlsoap.org/soap/envelope/}Envelope -

python - How to remove the Xframe Options header in django? -