Populate dropdown with MySQL query results (PHP/MySQL) -


So says as the title .....

Here is the code that I It is written in the present thinking and it will not work: (

Note that my session user is working etc. Because I can print it in any other field in the form so that there is no problem , But there is just nothing in my dropbox. (I have created the data of that database with user_id, in which I am logged in)

  $ userid = $ _SESSION ['myuserid']; // run query database $ Query = "SELECT * test_groups_tb WHERE user_id = '$ userid'" mysql_query ( $ Query) or die (mysql_error ()); while ($ row = mysql_fetch_assoc ($ query)) {$ dd. = "& Lt; option value = '{$ row [' group_id ']}' & gt; {$ Row ['group_name']}  "}}   

This is then used in HTML:

  & lt ; Select name = "t_group"> echo $ dd;? & Gt;   

Can someone help me out? ?

Thanks

$ qu Ery is a string And so you can not get results. You should do something like this:

  $ query = "SELECT * test_groups_tb WHERE user_id = '$ userid'"; $ Result = mysql_query ($ query) or die (mysql_error ()); {$ Row = mysql_fetch_assoc ($ result)) {$ dd. = "& Lt; option value = '{$ row [' group_id ']}' & gt; {$ row ['group_name']} & lt; / option & gt; ; }    

Comments