2016-02-15 69 views
0

我有我的兩個IF ELSE語句示數出來,但不是第三個問題。的if else變量問題

注意:試圖讓非對象的財產employees2.php線51個 0結果

// Pass appropriate SQL to the database 
$lname = htmlspecialchars($_POST["lname"]); 
$fname = htmlspecialchars($_POST["fname"]); 
$empid = htmlspecialchars($_POST["empid"]); 

echo "<h3>Search results.</h3>"; 
$sqlL = "SELECT * FROM employees WHERE LAST_NAME = \"" . $lname . "\""; 
$sqlF = "SELECT * FROM employees WHERE FIRST_NAME \"" . $fname . "\""; 
$sqlID = "SELECT * FROM employees WHERE EMPLOYEE_ID \"" . $empid . "\""; 
$resultL = $conn->query($sqlL); 
$resultF = $conn->query($sqlF); 
$resultID = $conn->query($sqlID); 

if ($resultF->num_rows > 0) { 
    // Output data of each row 
    printf("\n\t<table><th>Name</th> 
         <th>Employee ID</th> 
      "); 
    while ($row = $resultF->fetch_assoc()) { 
     printf("\n\t<tr><td>%s%s</td> 
         <td>%s</td></tr>", 
       $row["LAST_NAME"], $row["FIRST_NAME"], $row["EMPLOYEE_ID"]); 
    } 

    echo "</table>\n"; 
    echo "<h5><strong>($resultF->num_rows) results returned.</strong></h5><br>"; 
} else { 
    echo "0 results "; 
} 
+0

你缺少你'='在'$ sqlF' && '$ sqlID'查詢 - >'... WHERE FIRST_NAME \「」。 $ fname。 「\」「;'/'...WHERE EMPLOYEE_ID \」「。$ empid。」\「」;'。所以,你的查詢失敗,那麼你的'$ resultF'和'$ resultID'會導致'非object's – Sean

回答

0

嘗試while ($row = mysql_fetch_assoc($resultF))

+0

會從OOP到程序的風格改變如何解決有機磷農藥的問題? – Sean

+0

沒有快樂。給我 –

+0

不起作用。現在我得到一個**通知:嘗試獲取非對象**錯誤的屬性。 –