PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!
basically when you use the drop to perform a search it all works fine and pulls the correct results from the database expect when you do a search for the first term in the array - in this case hotel / catering jobs where by the full results are shown.
<?php
function career_level($c, $id) {
$levels = array("Hotel / Catering Jobs", "Industrial / Warehouse Jobs", "Office Jobs", "Sales Jobs");
// This does not need quotes
// Also, what if $id is 45667564? Perhaps you could check ...
if($id >= 0 && $id <= count($levels)) {
return $levels[$id]; // No need for an assignment either
} else {
$select = '<select name="careerlevel">' . "\n\t";
// I am more of the foreach guy myself, mainly because of the reset pointer
foreach($levels as $k => $v) {
// Again, no need for quotes
// In fact, no need for this equality check here
$selected = $c == $k ? ' selected="selected"' : '';
$select .= '<option value="' . $k . '"' . $selected . '>' . $v . '</option>' . "\n\t";
}
$select .= '</select>' . "\n\n";
return $select;
}
}
?>