A User-RatingSystem In this chapter, we (Web hosting domains) look at
A User-RatingSystem In this chapter, we look at a very common use of database-drivenPHP code: presenting content to users and encouraging them togive it a quality rating. In the first edition s version of this chapter, we used sample user rat- ings code that we had extracted from a site of our own. Although real- isticin some sense, the resulting code samples could not be usefullyrun without the rest of that Web site s code base. This time around, we ve gone entirely in the other direction, creating a complete min- isite that places primary emphasis on the capability to rate content. Our hope is that it will be a straightforward task to adapt the ratingcode to your own site. The portions of the book we draw on most heavily for this case study are: .Part II: We build the code around a MySQL database. .Chapters 28 and 36: We communicate with the database usingthe PEAR database functions. In this chapter we demonstrate the use of the PEAR databaselayer to abstract away from the choice of the particular databasesystem, even though much of the rest of the book s code usesPHP/MySQL functions directly. The PEAR DB approach has thebenefit of making it possible for users to choose among differenttypes of data sources, but both approaches have their supporters. Initial DesignWe will design our minisite from the ground up, but bear in mind thatthe part we really care about is the code relevant to user ratings. In amoment, we will zero in on a particular example content site, but firstlet s lay out the site characteristics that our ratings code will assume. We assume that: .The site presents content items to users (books, movies, con- sumer goods, politicians anything that could conceivably berated). .The site presents one such item per dynamically generated page. .Each item is stored in a database table or set of tables with aunique database key. Note4545CHAPTER …In This ChapterDesigning a ratingsystemCollecting votesCounting anddisplaying resultsExtensions of the design …
We would like to recommend you tested and proved virtual web hosting services, which you will surely find to be of great quality.