2016-06-29 5 views
1

다음 코드가있는 PHP를 사용하여 입력 항목에 mongodb의 콜렉션을 표시 할 수 있습니다. 입력 필드에 입력 한 데이터가 표시하려는 컬렉션과 일치하지 않을 때 **이 이름은 데이터베이스에서 찾을 수 없습니다 **. 여기 붙어있어 메시지를 표시 할 수 없다.데이터 검색 MongoDB/ph

데이터베이스에 데이터가없는 경우 메시지를 표시하는 데 도움을 얻고 싶습니다. 감사합니다.

답변

1

왜 다른 사람을 사용하지 않습니까?

if($c_users->count()>0){ 
    echo '<table> 
      <tr> 
       <th>firstname</th> 
       <th>lastname</th> 
       <th></th><th> 
      </tr>'; 
    foreach($get_users1 as $user) 
    { 
     echo '<tr> 
      <td>' . $user['firstname'] . '</td> 
      <td>' . $user['lastname'] . '</td> 
      <td><a href="update_user.php?edit=' . $user['_id'] . '">Modifier</td> 
      <td><a href="delete_user.php?delete='.$user['_id'].'" onclick="return confirm(\'Do you really want to delete this user ?\')">Supprimer</td> 
      </tr>'; 
    } 
     echo '</table>'; 
} else { 
    echo 'This name is not found in database !';  
} 
+0

여전히 작동하지 않습니다. – Diasline

+0

'empty ($ get_users1)'을'empty ($ c_users) '로 변경하면 어떨까요? (나는 결코 MongoDB를 사용하지 못했다.) 그러나'$ get_users1'이 결코 비어 있지 않다는 것을 알 수있다. – Sebastian

+0

여전히 작동하지 않습니다. – Diasline