Looks logical What I did right now:
I have two tables:
- users (ID - Name - Address - etc)
- messages (name - subject - viewed - live)
The VIEWED is the serialized array of all user ID’s, which where grabbed from table1 at the moment the message was saved. So basicly, all users whom are registered at that moment.
The LIVE is the serialized array of all user ID’s, not regarding the ACTIVE-state of a user. So if a user has left (not gonna use the messageboard anymore), his details are still stored in table 1. A simple value of “yes/no” in the ACTIVE row will tell mysql whether an user’s still active or not. I need this so if a new user registers, he’ll still be able to check (and mark) messages which where posted before his registration. So, the names may be confusing, I know, but the LIVE holds all user ever registered, the VIEWED holds just the users who’re still active. This row can be changed I guess, because these are the values which will tell if the user has marked the message.
I hope I explained it clearly? Are you still following me what I’m trying to say?
Then,
I used your untested code and modified it to this:
[php]$query=“SELECT viewed FROM $tbl_name”;
$result = mysql_query($query) or die(mysql_error());
$query3=“SELECT live FROM $tbl_name”;
$result3 = mysql_query($query3) or die(mysql_error());
while($rs3=mysql_fetch_assoc($result3))
{
$user_id= unserialize($rs3[‘viewed’]);
}
// Previously, you loaded all IDs into the $user_id array
// Now grab NON-viewed IDs
$rs=mysql_fetch_assoc($result);
$viewed = unserialize($rs[‘viewed’]);
// Loop thru all IDs, checking if they are viewed or not...
foreach ($user_id as $user) {
echo "Used ID #" . $user; // show user id for this user only
if ( in_array($user, $viewed) ) {
echo " - Not Viewed Yet<br>"; // This is where you would insert their non-viewed pix-icon
} else {
echo " - Already Viewed<br>"; // Insert the already-viewed pix-icon here
}
}[/php]
But this results in 16 lines of errors:
Used ID #Array
Warning: in_array() expects parameter 2 to be array, boolean given in /nfs/home/deb22994/domains/entertainyou.nl/public_html/whatsup/FunEntertainmentLGN/unserialize_array.php on line 33
line 33:[php]if ( in_array($user, $viewed) ) {[/php]
And yes, this is party of the other thread, but I think I’m not gonna continue with that problem, it’s causing too many problems. I’ll keep that the old (working) way. This thread is the main problem.