I used php since the java code I used were bit difficult for me to retrieve the information from the database and add them to the drop down. I was retrieving them using the below function but I have no idea of how to add the retrieved data to the drop down list. private List listOfTeams;
public void returnTeamListfromDB() {
listOfTeams = new ArrayList<DepartmentBean>();
Connection connection = DB.getCon();
try {
Statement statement = connection.createStatement();
/* select from the databse but in an ascending order ASC */
ResultSet result = statement.executeQuery("select department_id from departments order by department_id ASC");
while (result.next()) {
DepartmentBean department = new DepartmentBean();
String nameFromDB = result.getString("department_id");
int oya = Integer.parseInt(nameFromDB);
department.setId(oya);
/* add object to in the team list */
listOfTeams.add(department);
}
connection.close();
}
catch (SQLException e)
{
// TODO Auto-generated catch block
e.printStackTrace();
}
}