投稿の表示を許可されているユーザーをスキャンするこのスクリプトを以下に示します。閲覧者のIDがフィールドに保存されているIDと一致するように更新するにはどうすればよいですか。一致する場合は機能し、そうでない場合は機能しません。保存されるエントリは、99394david、324234smith、34343janeのようになります。したがって、私が持っているこのスクリプトはそれと一致していません。
$kit = mysql_real_escape_string($_GET['id']);
$sql="SELECT `Who_can_see` from `posts` where `post_id` = '$kit'";
$result=mysql_query($sql);
$query = mysql_query($sql) or die ("Error: ".mysql_error());
if ($result == "")
{
echo "";
}
echo "";
$rows = mysql_num_rows($result);
if($rows == 0)
{
print("");
}
elseif($rows > 0)
{
while($row = mysql_fetch_array($query))
{
$userallowed = htmlspecialchars($row['who_can_see']);
}
}
//$personid is drawn from the database. its the id of the
person viewing the link.
if ( $userallowed == $personid ) {
echo("allowed");
} else {
echo("not allowed");
die();
}
?>