tailieunhanh - PHP and MySQL Web Development - P108

PHP and MySQL Web Development - P108: PHP and MySQL Web Development teaches the reader to develop dynamic, secure, commercial Web sites. Using the same accessible, popular teaching style of the first edition, this best-selling book has been updated to reflect the rapidly changing landscape of MySQL and PHP. | Implementing Recommendations 507 where valid_user and and This query uses aliases to join the database table bookmark to itself a strange but sometimes useful concept. Imagine that there are actually two bookmark tables one called b1 and one called b2. In b1 we look at the current user and his bookmarks. In the other table we look at the bookmarks of all the other are looking for other users who have an URL the same as the current user and are not the current user . This query will give us a list of like-minded people to our current user. Armed with this list we can search for their other bookmarks with the following 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 The variable sim_users contains the list of like-minded users. The user_urls variable contains the list of the current user s bookmarks if b1 already has a bookmark there s no point in recommending it to him. Finally we add some filtering with the popularity variable we don t want to recommend any URLs that are too personal so we only suggest URLs that a certain number of other users in the list of like-minded users have bookmarked. If we were anticipating a lot of users using our system we could adjust popularity upwards to only suggest URLs have been bookmarked by a large number of users. URLs bookmarked by many people might be higher quality and certainly have more general appeal than an average Web page. The full script for making recommendations is shown in Listing and . The main script for making recommendations is called see Listing . It calls the recommender function recommend_urls from see Listing . Listing This Script Suggests Some Bookmarks That a User Might Like php require_once session_start .

TỪ KHÓA LIÊN QUAN