Hi,
I want to know how to select data from a database with two drop down menu.
I can select a data from mysql database with one drop down menu. But I don't know how to combine two drop down menu to select data from database and show it in a table.

Member Avatar for diafol

You could try something like this:

if(isset($_POST['dd1']) || isset($_POST['dd2'])){
    //assuming inputs should be integers
    if(isset($_POST['dd1'])) $where[] = "`field1` = " . intval($_POST['dd1']);
    if(isset($_POST['dd2'])) $where[] = "`field2` = " . intval($_POST['dd2']);
    $whereclause = implode(" AND ", $where);
    $sql = mysql_query("SELECT ... WHERE $whereclause");
    ...
}
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.