php - Populate dropdown box won't show up database -


i'm trying populate dropdown box retrieve database mysql. here form , php files below. looks alright me, don't why doesn't show thing when click on submit button. there can fix error? correction , suggestion appreciated.

cs_jobs table consists of: job_title, category_code (17, 27, 37....), ...etc.

connect.php works fine in case.

my form

<!doctype html> <html>     <head></head>     <body>         <form action = "csjob.php" method = "post" name = "jobsearch">             <select name = "category_code[]">                 <option value = "17">architecture , engineering</option>                 <option value = "27">arts, design, entertainment, sports, , media</option>                 <option value = "37">building , grounds cleaning , maintenance</option>                 <option value = "13">business , financial operations</option>                 <option value = "21">community , social services</option>                 <option value = "15">computer , mathematical</option>                 <option value = "47">construction , extraction</option>                 <option value = "25">education, training, , library</option>                 <option value = "45">farming, fishing, , forestry</option>                 <option value = "35">food preparation , serving related</option>                 <option value = "29">healthcare practitioner , technical</option>                 <option value = "31">healthcare support</option>                 <option value = "49">installation, maintenance, , repair</option>                 <option value = "23">legal</option>                 <option value = "19">life, physical, , social science</option>                 <option value = "11">management</option>                 <option value = "43">office , administrative support</option>                 <option value = "39">personal care , service</option>                 <option value = "51">production</option>                 <option value = "33">protective service</option>                 <option value = "41">sales , related</option>                 <option value = "53">transportation , material moving</option>             </select>             <input type="submit" value="submit">          </form>     </body> </html> 

csjob.php

<?php      require("connect.php");     if(isset($_post['submit'])){         $sql = "select * cs_jobs category_code=".$_post['category_code'];         $result = mysql_query($sql);          echo "<select name='category_code'>";         while ($row = mysql_fetch_array($result)) {             echo "<option value='".$row['job_title']"'>".$row['job_title']"</option>";         }         echo "</select>";     } ?> 

so many typos in question, here actual code upload: a link!

you have 3 small problems. first 1 in form:

<select name = "category_code[]"> 

should be

<select name="category_code"> 

so without brackets [] in name , no need spaces...
brackets needed if have option has multiple select, , return array (hence brackets). isn't happening in case.

and second problem said before: in php:

$row['job_title'} 

should be

$row['job_title'] 

so change } ]

your third problem has checking submit:

if(isset($_post['submit'])){ 

should be

if(isset($_post['category_code'])){ 

because don't have field name 'submit'. have field id submit , value submit. no name submit. can add name='submit' submit button. or go proposed change above...


Comments

Popular posts from this blog

c++ - Creating new partition disk winapi -

Android Prevent Bluetooth Pairing Dialog -

VBA function to include CDATA -