RE: Populate Array During Loop With in_array - FIXED

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Really have to apologize. I tested the previous code too hastily before I
posted it, and additional testing after I posted it proved that it broke
with multiple items marked as read. Here is the fixed code. Hopefully I've
plugged the holes. Sorry for any inconvenience to anybody actually paying
attention to this thread.

Rich


		$sql_getNews = "SELECT newsID FROM news WHERE CURDATE()
BETWEEN startDate AND endDate";

		$result_getNews = mysql_query($sql_getNews)
			or die(mysql_error());

		$sql_getReadItems = "SELECT newsID FROM newsReadBy WHERE
userID='".$creatorID."'";

		$result_getReadItems = mysql_query($sql_getReadItems)
			or die(mysql_error());

		while($row = mysql_fetch_array($result_getReadItems)){
			$readList[] = $row["newsID"];
		}

		//check to see if a valid newsID ($newsList["newsID"]) has
already been read (appears in $readList)
		while($newsList = mysql_fetch_array($result_getNews)){
			if(isset($readList)){
				if (!in_array($newsList["newsID"],
$readList)){
					$displayThese[] =
$newsList["newsID"];
				}
			}
			else{
				$displayThese[] = $newsList["newsID"];
			}
		}
		if(isset($displayThese)){
			return $displayThese;
		}
		else{
			$displayThese = NULL;
			return $displayThese;
		}


-- 
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


[Index of Archives]     [PHP Home]     [PHP Users]     [Postgresql Discussion]     [Kernel Newbies]     [Postgresql]     [Yosemite News]

  Powered by Linux