lordzardeck Posted April 13, 2009 Share Posted April 13, 2009 For some reason I keep getting a result when there is no result to return. I know for sure no books are checked out to me, but it still returns a result. If i use num_rows, I get the result "1"; The code to check if books are due is this: function patronbooks($patronid,$overdue=""){ if($overdue=="yes"){ $sql = "SELECT * FROM circulation WHERE "; $patron_query = "SELECT * FROM circulation WHERE patronid = $patronid"; $patron_books = self::$db->query($patron_query); while($row=self::fetch_row($patron_books)){ $formatedDate = self::convertTimeToPHP($row[datedue]); if($formatedDate[year]==2008){ $sqlArray[] = $row; } } $numSql = count($sqlArray); $i=1; $and = 'OR '; if(is_array($sqlArray)){ foreach($sqlArray as $row){ if($i==$numSql){$and='';} $sql .= "circulationid = $row[circulationid] $and"; $i++; } } if($sql!="SELECT * FROM circulation WHERE "){$patron_books = self::$db->query($sql);} else{return;} }else{ $patron_query = "SELECT * FROM circulation WHERE patronid = $patronid"; $patron_books = self::$db->query($patron_query); } return $patron_books; } And the code that calls it is: $overdue = $_POST['overdue']; if($_POST['includebooks']){ $books = self::patronbooks($patron['patronid'],$overdue); $numbooksout = self::$db->num_rows($books); if(!$books && $overdue){print "No overdue books!"; return;} if(!$overdue){print "Not overdue!";} echo $books; if(!$books){print "Not books!";} if(!$books && !$overdue){print "No books checked out!"; return;} $msg = self::generateEmailMessage($books, $patron, $_POST['usrmsg']); }else{$msg = $_POST['usrmsg'];} Thanks in advance for any help you can give. Link to comment https://forums.phpfreaks.com/topic/153909-returning-result-when-there-is-none/ Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.