Page 1 of 1

Go through blocked list

Posted: Sun Mar 20, 2005 7:58 pm
by cbrian
I'm writing a mail service for my game, and I'm having trouble figuring out how not to show the mails sent by someone on the users blocked list. Here's what I have so far to show the mails:

Code: Select all

$i = 0;

print("<td>");
$q = mysql_query("SELECT * FROM `blocked` WHERE `by`='$userid' AND `who`='{$mail['from']}'");

while(($mail=mysql_fetch_assoc($query)) && ($i <= 30) && (mysql_num_rows($q) == "0")) {
if($mail['read'] == "0") {
$b = 'style=\"font-weight:bold\"';
}
$from = mysql_query("SELECT username FROM users WHERE userid='{$mail['from']}'");
$from = mysql_fetch_array($from);
$from = $from[0];

$datetime = explode(' ', $mail['datetime']);
$date = $datetime[0];
$time = $datetime[1];
$date = explode("-", $date);
$month = $date[1];
$day = $date[2];

$date = $month . '/' . $day;
$date = $date . ' ' . $time;
if($mail['read'] == "0") {
print("<tr><td class=\"bold\" colspan=1><b>{$date}</b></td>
<td class=\"bold\" colspan=1><b><a style=\"color:black\" href=\"game.php?where=messenger&stamp=$timestamp&do=read&read={$mail['id']}\" title=\"{$mail['message']}\">{$mail['subject']}</a></b></td>
<td class=\"bold\" colspan=1><b><a style=\"color:black\" href=\"game.php?where=profile&stamp=$timestamp&who={$mail['from']}\">{$from}</a></b></td></tr>");
} else {
print("<tr><td colspan=1>{$date}</td>
<td colspan=1><a style=\"color:black\" href=\"game.php?where=messenger&stamp=$timestamp&do=read&read={$mail['id']}\" title=\"{$mail['message']}\">{$mail['subject']}</a></td>
<td colspan=1><a style=\"color:black\" href=\"game.php?where=profile&stamp=$timestamp&who={$mail['from']}\">{$from}</a></td>
<td colspan=1><a style=\"color:black\" href=\"game.php?where=messenger&stamp=$timestamp&do=inbox&delete=yes&id={$mail['id']}\">DEL</a></td></tr>");
}
$i++;
}

Posted: Sun Mar 20, 2005 8:12 pm
by John Cartwright
and specifically the problem is?

Posted: Sun Mar 20, 2005 8:21 pm
by cbrian
I'm writing a mail service for my game, and I'm having trouble figuring out how not to show the mails sent by someone on the users blocked list.

Posted: Sun Mar 20, 2005 8:25 pm
by John Cartwright
Phenom wrote:and specifically the problem is?
What is being returned? Have you tried inserting debugging outputs?
Are you outputting your variables so they are as expected?

Posted: Sun Mar 20, 2005 8:36 pm
by cbrian
Sorry, what I'm trying to say is that I am just not sure how to put it through something to make sure the mail is not from someone who's blocked.

Posted: Sun Mar 20, 2005 9:14 pm
by hongco
i am a bit confused...anyway, is it right that your script will let users to send emails, and you don't want to show the emails belong to blocked users? If so, my suggestion is that if any users who are on the blocked list, he/she will not be given permission to send email.

the below query will yield info of those who are Not on the blocked list. I am not sure if this is waht you are trying to do?

Code: Select all

$query = "SELECT * FROM users u, blocked b where u.user_id != b.user_id";

Posted: Sun Mar 20, 2005 11:37 pm
by feyd
hongco's query will return multiples of rows.. all of which will be false.. I posted how to do exclusion lists before in the "useful posts thread" :: Find all records that aren't matching: SQL SELECT JOIN HELP