SQL QUERY
if ($_SERVER == 'POST') {
if ($_POST == 'm2') {
$sql="SELECT Products, TABLE 1";
$rs=odbc_exec($conn,$sql);
}
elseif ($_POST == 'm3') {
$sql="SELECT Products, Table2";
$rs=odbc_exec($conn,$sql);

FORM 1
echo '
<form name="input" action="kkl.php" method="GET"> <div align= "left">
<b>City:</b>
<select NAME="list1">
<OPTION VALUE="m1"></option>
<OPTION VALUE="m2">London</option>
<OPTION VALUE="m3">Paris</option>
<OPTION VALUE="m4">Tokoyo</option>
</select>
<br/><br/>
<b>Monthly Class:</b>
<select NAME="list2">
<OPTION VALUE="m1"></option>
<OPTION VALUE="m2">First Class</option>
<OPTION VALUE="m3">Economy</option>
</select>

Please how can I write a query that if a customer selects m2 FROM list1 AND m3 FROM list2 it should display Table 1 and if the customer select m3 FROM list1 and m2 FROM list2 it should display Table2. I look forward to your replies and thanks very much in advance

if($_POST['list1']=='m2'  && $_POST['list2']=='m3') {
//show from table1
}
elseif($_POST['list1']=='m3' && $_POST['list2']=='m2') {
 //show from table1
} else {
 //some other option was selected
}

Unless you have some logic to know what to do on selection of particular option, you have to build your script with alot of if's and else.
And please, next time, use [code] tags to wrap your code.

Btw, Your form method is GET. $_POST will not work.

Thanks for your reply and advice but I have changed the form from $GET to $POST but when I click the submit buttom it does not show the table. Please advice

Can you post relevant code using tags ?[code=php] tags ?

SQL QUERY 
if ($_SERVER ['REQUEST_METHOD'] == 'GET') {
if ($_GET['mylist1'] == 'm2' && $_GET['mylist2'] =='m2') {
$sql="SELECT Products, TABLE 1";
$rs=odbc_exec($conn,$sql);
}
elseif ($_GET['mylist'] == 'm3' && $_GET['mylist3'] =='m3') {
$sql="SELECT Products, Table2";
$rs=odbc_exec($conn,$sql);

FORM 1
echo '
<form name="input" action="kkl.php" method="GET"> <div align= "left">
<b>City:</b>
<select NAME="list1">
<OPTION VALUE="m1"></option>
<OPTION VALUE="m2">London</option>
<OPTION VALUE="m3">Paris</option>
<OPTION VALUE="m4">Tokoyo</option>
</select>
<br/><br/>
<b>Monthly Class:</b>
<select NAME="list2">
<OPTION VALUE="m1"></option>
<OPTION VALUE="m2">First Class</option>
<OPTION VALUE="m3">Economy</option>
</select>

Umm.. In the above posted code, select box's name is list1 and list2. But, in the condition, you are trying to access mylist.

($_GET == 'm2' && $_GET =='m2') {

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.