在PHP中无法从数据库中找到数据

时间:2018-08-01 07:26:43

标签: php ms-access odbc

今天或当前日期生日日期是从Ms Access数据库中检索的。假设今天日期是2018年3月8日。我仅传递了值,日期和月日= 03,月= 08,年未通过。因此,我检索了当前的日期和月份记录。

PHP文件中进行

数据检索查询。此查询在Ms Access数据库中运行成功,并获取当前日期记录,但在PHP文件中提供空数据。

url中传递数据,就像这样:localhost/Bi.php?Chhaprabhatha&mon=8&day=3

它给出如下结果:Resource id #4{"status":0,"0":[]}

查询在数据库中运行,并给出结果并成功运行。在此代码中提供空数据

Bi.php

  <?php

        if(isset($_REQUEST["Chhaprabhatha"])) 
        { 

        include 'Connection.php';


        $mon = $_GET['mon'];
        $day = $_GET['day'];

        $sql = "select std_name, regno,standard,division
        FROM(select RegNo,b.Standard,c.Division,std_name,DOB as BirthDayDate,contactno1 as contact, Year(DOB) AS OrderYear,  month(DOB) AS OrderMonth,Day(DOB) AS OrderDay,a.YearID,IsActive
         from ((std_reg as a inner join standardmaster as b on a.standard = b.stdid)
        inner join divisionmaster as c on a.division = c.divisionid)
        ) as t where (t.OrderMonth = $mon AND t.OrderDay = $day  and t.Isactive = true)";


        echo $stmt = odbc_exec($conn, $sql);

        $result = [];
        do {
            while ($row = odbc_fetch_array($stmt)){
               $result[] = $row; 
            }
        } while (odbc_next_result($stmt));

        if(count($result)>0)
        {
            $result1['status']=1;//"Login successfully";
            echo array_push($result1,$result);
        }
        else
        {
             //$result[]="null";
            $result1['status']=0;//"Record not found";
            array_push($result1,$result);
        }
        odbc_free_result($stmt);
        odbc_close($conn); //Close the connnectiokn first

        echo json_encode($result1); //You will get the encoded array variable

        }
?>

0 个答案:

没有答案