逻辑错误或语法错误?

I want to perform a query in result page that select the information that bigger than a form data pass from index page.

The value passed from index page is correct which as seen as below:

Array
(
[device] => sim only
[provider1] => umobile
[plantype] => postpaid
[dusage] => 3
[cusage] => 0
[musage] => 300
)

but my result show is not as expected. I wonder is my logic error or my syntax error?

Here is my query code:

 <?php
                //$planquery="SELECT * FROM plan";
                $dquery= "SELECT * FROM details";
                $device = $_POST['device'];
                $provider1 = $_POST['provider1'];
                //$provider2 = $_POST['provider2'];
                //$provider3 = $_POST['provider3'];
                //$provider4 = $_POST['provider4'];
                $plantype = $_POST['plantype'];
                $dusage = $_POST['dusage'];
                $cusage = $_POST['cusage'];
                $musage = $_POST['musage'];
                $planquery="SELECT * FROM plan WHERE 
                            Phone='$device' AND SIMTYPE='$plantype' AND 'DATA'>='$dusage' AND 'CALL'>='$cusage' AND 'MSG'>='$musage' "; 
                $planresult=mysql_query($planquery) or die ("Query to get data from firsttable failed: ".mysql_error());
                $dresult=mysql_query($dquery) or die ("Query to get data from firsttable failed: ".mysql_error());
                //$sresult=mysql_query($squery) or die ("Query to get data from firsttable failed: ".mysql_error());
                while ((($prow = mysql_fetch_assoc($planresult))) && ($drow = mysql_fetch_assoc($dresult)) ) {

                ?>

I have two details which is

  1. 500 free msg
  2. 200 free msg

Form data is contain user search require, in case user search for 500msg. The query I want to do is only select the record that when 'MSG'>='$musage' also other requirement. The both result shown as result; this is what is not as expected.

(Posted solution on behalf of the OP).

I solved this question by restructure the table, so that it is more easy to do query. Left Join used by me, rather than pull from both table.