Sending MySQL queried checkbox form data to PHP script -


as title states, i'm trying send html form checkbox data (that supposed query mysql database) php script output should table of queries' results. have 1 document html , php/sql. the query works fine in mysql when try executing through html/php, column names results table no queried results. problem.

the database groups users groups , groups departments. query finds user vacancies (where user_id=1) within departments. imagine it's php that's screwing me up. here's have far--

the html form:

<form name="dept_checkbox" method="post" action="dept.php"> <fieldset> <legend>in department find open positions?</legend><br /> <input type="checkbox" name="dept_name" id="dept_name" value="first department" />first department<br /> <input type="checkbox" name="dept_name" id="dept_name" value="second department" />second department<br /> <input type="checkbox" name="dept_name" id="dept_name" value="third department" />third department<br /> <input type="checkbox" name="dept_name" id="dept_name" value="fourth department" />fourth department<br /> <input type="checkbox" name="dept_name" id="dept_name" value="fifth department" />fifth department<br /> <input type="checkbox" name="dept_name" id="dept_name" value="all departments"/>all departments<br /><br /> <input type="submit" value="submit" /> </fieldset>    

the above displays fine in browser. following failed attempt run sql query through php. @ point, i'm trying work 1 department ("first department") and, once work, figure can go there. here's sql/php minus database login info @ beginning of script:

if(isset($post[dept_name])){   $sql="select user_role,group_name   groups,users,groups_users_link,departments   groups.group_id=groups_users_link.groups_id   , users.user_id=groups_users_link.user_id   , groups.department_id=departments.department_id   , league_name \"first department\"   , groups_users_link.user_id=1";   $result=mysql_query($sql); } 

let me reiterate above query working in mysql. following rest of php script supposed display results in table form:

echo("<table border=\"10px\">"); echo("<tr><th>role</th><th>group</th></tr>"); while($myrow=mysql_fetch_array($result)) { echo("<tr><td>".$myrow[user_role]."</td>"); echo("<td>".$myrow[group_name]."</td>"); } echo("</table>"); ?> <h4><a href="dept.html">back form</a></h4> 

i'm wanting display vacant user roles such-and-such groups within department "first department." instead displays column names the query results missing. appreciated.

in html checkboxes, use array notation checkbox names:

name="dept_name[]"

then when processing posted form, have error $post should $_post.

finally, switch mysqli or pdo if possible. mysqli functions can used in similar fashion mysql, it's easy switch if aren't in large legacy codebase.