Specifications

// create set of users with urls in common
// for use in IN clause
$row = mysql_fetch_object($result);
$sim_users = “(‘“.($row->username).”’”;
while ($row = mysql_fetch_object($result))
{
$sim_users .= “, ‘“.($row->username).”’”;
}
$sim_users .= “)”;
// create list of user urls
// to avoid replicating ones we already know about
if (!($result = mysql_query(“
select bm_URL
from bookmark
where username=’$valid_user’”)))
return false;
// create set of user urls for use in IN clause
$row = mysql_fetch_object($result);
$user_urls = “(‘“.($row->bm_URL).”’”;
while ($row = mysql_fetch_object($result))
{
$user_urls .= “, ‘“.($row->bm_URL).”’”;
}
$user_urls .= “)”;
// as a simple way of excluding people’s private pages, and
// increasing the chance of recommending appealing URLs, we
// specify a minimum popularity level
// if $popularity = 1, then more than one person must have
// an URL before we will recommend it
// find out max number of possible URLs
if (!($result = mysql_query(“
select bm_URL
from bookmark
where username in $sim_users
and bm_URL not in $user_urls
group by bm_URL
having count(bm_URL)>$popularity
“)))
return false;
Building User Authentication and Personalization
C
HAPTER 24
24
AUTHENTICATION
AND
PERSONALIZATION
535
LISTING 24.27 Continued
30 7842 ch24 3/6/01 3:34 PM Page 535