php
  • mysql
  • row
  • row-number
  • 2014-07-07 60 views -1 likes 
    -1

    給出其實我正在尋找如何選擇在mysql表中的單元格值。mysql - 空列列表 - 錯誤:mysqli_num_rows()期望參數1是mysqli_result,布爾在

    請幫助...

    // checking the break already taken? 
    
        $verify = mysqli_query($conn, "SELECT COUNT(*) AS count FROM attend WHERE EmployeeNoA='$EmployeeNoA' AND SignInDate='$BreakDate' AND BreakOut_I==''"); 
        $row = mysqli_num_rows($verify); 
        echo $row; 
    
         // If they didn't taken the break 
         if ($row == 0) 
         { 
         echo "<script>alert ('You Have Already 1st Break Out');</script>"; 
         } 
         else 
         { 
         $SignInDate = $BreakDate; 
         $ver = "UPDATE attend SET BreakOut_I='$BreakTime' WHERE EmployeeNoA='$EmployeeNoA' AND SignInDate='$BreakDate'"; 
         if (!mysqli_query($conn, $ver)) 
         { 
         echo mysqli_error($conn); 
         } 
         else 
         { 
         echo "<script>alert ('You have 1st Break Out to GO!');</script>"; 
         } 
         } 
    

    我需要的行數,其中的突破就相當於爲null,員工沒有和日標從輸入值給出

    請找完整的PHP編碼

    <?php 
    
    $conn = mysqli_connect("localhost", "Vijay", "vijay123", "test"); 
    if (mysqli_connect_errno()) 
    { 
    echo "Unable to connect the Server" . mysqli_connect_error(); 
    } 
    
    if ($_SERVER["REQUEST_METHOD"] == "POST") 
    { 
    
    $EmployeeNoA=mysqli_real_escape_string($conn, $_POST['EmployeeNoA']); 
    $EmployeeNameA=mysqli_real_escape_string($conn, $_POST['EmployeeNameA']); 
    $Break=mysqli_real_escape_string($conn, $_POST['Break']); 
    $SignInDay=mysqli_real_escape_string($conn, $_POST['SignInDay']); 
    $BreakDate=mysqli_real_escape_string($conn, $_POST['BreakDate']); 
    $BreakTime=mysqli_real_escape_string($conn, $_POST['BreakTime']); 
    
        if ($Break != "0") 
        { 
        $ver = mysqli_query($conn, "SELECT COUNT(*) AS count FROM attend WHERE EmployeeNoA='$EmployeeNoA' && SignInDate='$BreakDate'"); 
        $row = mysqli_fetch_assoc($ver); 
        if ($row['count'] == 0) 
        { 
        echo "<script>alert ('You are not SignIn Yet! \\n Please Sign In...');</script>"; 
        } 
        else 
        { 
        $Breaks = $Break; 
         switch ($Breaks) 
         { 
         case ($Breaks == 'breakout1'): 
    
         // checking the break already taken? 
    
         $verify = mysqli_query($conn, "SELECT COUNT(*) AS count FROM attend WHERE (EmployeeNoA='$EmployeeNoA') AND (SignInDate='$BreakDate') AND (BreakOut_I=='' OR IS NULL(BreakOut_I))"); 
         $row = mysqli_num_rows($conn, $verify); 
    
    echo "SELECT COUNT(*) AS count FROM attend WHERE (EmployeeNoA='$EmployeeNoA') AND (SignInDate='$BreakDate') AND (BreakOut_I=='' OR ISNULL(BreakOut_I))"; 
    
    
          // If they didn't taken the break 
          if ($row == '0') 
          { 
          echo "<script>alert ('You Have Already 1st Break Out');</script>"; 
          } 
          else 
          { 
          $SignInDate = $BreakDate; 
          $ver = "UPDATE attend SET BreakOut_I='$BreakTime' WHERE EmployeeNoA='$EmployeeNoA' AND SignInDate='$BreakDate'"; 
          if (!mysqli_query($conn, $ver)) 
          { 
          echo mysqli_error($conn); 
          } 
          else 
          { 
          echo "<script>alert ('You have 1st Break Out!');</script>"; 
          echo "SELECT COUNT(*) AS count FROM attend WHERE (EmployeeNoA='$EmployeeNoA') AND (SignInDate='$BreakDate') AND (BreakOut_I=='' OR IS NULL(BreakOut_I))"; 
          } 
          } 
         break; 
    
    
    
    
    
         case ($Breaks == 'breakin1'): 
         echo "<script>alert ('breakin1');</script>"; 
         break; 
         case ($Breaks == 'lunchout'): 
         echo "<script>alert ('lunchout1');</script>"; 
         break; 
         case ($Breaks == 'lunchin'): 
         echo "<script>alert ('lunchin1');</script>"; 
         break; 
         case ($Breaks == 'breakout2'): 
         echo "<script>alert ('breakout2');</script>"; 
         break; 
         case ($Breaks == 'breakin2'): 
         echo "<script>alert ('breakin2');</script>"; 
         break; 
         } 
    
        } 
    
        } 
        else 
        { 
        echo "<script>alert ('Please Select the Break');</script>"; 
        } 
    
    } 
    ?> 
    
    +0

    IT沒有搜索列Breakout_I – Vijay

    +0

    所以錯誤觸發爲空白或空值「警告:在給定的mysqli_num_rows()預計參數1被mysqli_result,布爾」回聲「你已經第一次爆發」。但BreakOut_I爲空... – Vijay

    回答

    0

    試試這個

    $verify = mysqli_query($conn, "SELECT COUNT(*) AS count FROM 
          attend WHERE (EmployeeNoA='$EmployeeNoA' AND 
          SignInDate='$BreakDate') AND 
          (BreakOut_I='' OR ISNULL(BreakOut_I)"); 
    
    +0

    它不工作...但我可以更新數據庫中的多個時間。並且錯誤「mysqli_num_rows()期望恰好1參數,2中給出」 – Vijay

    +0

    回聲此查詢並在phpmyadmin執行它返回什麼它只是告訴我 – Sadikhasan

    +0

    如果回聲使用下面的代碼代碼「$ verify = mysqli_query($ conn,」 SELECT COUNT(*)AS count FROM FROM WHERE(EmployeeNoA ='$ EmployeeNoA')AND(SignInDate ='$ BreakDate')AND(BreakOut_I ==''OR IS NULL(BreakOut_I))「); $ row = mysqli_num_rows( $康恩,$驗證); 而($行= mysqli_fetch_array($驗證)) 回聲$行; 「它仍然具有相同的錯誤,此錯誤太mysqli_fetch_array()預計參數1被mysqli_result,布爾給出 – Vijay

    0

    試試這個:

    $verify = mysqli_query($conn, "SELECT * FROM attend WHERE (EmployeeNoA='$EmployeeNoA' AND SignInDate='$BreakDate') AND (BreakOut_I='' OR ISNULL(BreakOut_I))"); 
    
    +0

    我需要等同於$ verify變量的行數。然而,空白「(BreakOut_I =''或ISNULL(BreakOut_I))」不起作用......總計數行總是等於0,msg「你已經第一次突破」,出現錯誤消息msg「mysqli_fetch_assoc()期望參數1是mysqli_result,布爾在「中給出。 – Vijay

    相關問題