douji9518 2016-09-09 03:18
浏览 41

逻辑错误或语法错误?

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.

  • 写回答

1条回答 默认 最新

  • duancai7002 2016-09-21 14:31
    关注

    (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.

    评论

报告相同问题?

悬赏问题

  • ¥20 我想使用一些网络协议或者部分协议也行,主要想实现类似于traceroute的一定步长内的路由拓扑功能
  • ¥30 深度学习,前后端连接
  • ¥15 孟德尔随机化结果不一致
  • ¥15 apm2.8飞控罗盘bad health,加速度计校准失败
  • ¥15 求解O-S方程的特征值问题给出边界层布拉休斯平行流的中性曲线
  • ¥15 谁有desed数据集呀
  • ¥20 手写数字识别运行c仿真时,程序报错错误代码sim211-100
  • ¥15 关于#hadoop#的问题
  • ¥15 (标签-Python|关键词-socket)
  • ¥15 keil里为什么main.c定义的函数在it.c调用不了