tailieunhanh - php solutions dynamic web design made easy phần 8

1 2 C R E AT I N G A D Y N A M I C O N L I N E GALLERY PHP SOLUTIONS: DYNAMIC WEB DESIGN MADE EASY What this chapter covers: Why storing images in a database is a bad idea, and what you should do instead Planning the layout of a dynamic gallery Displaying a fixed number of results in a row Limiting the number of records retrieved at a time Paging through a long set of results In the last chapter, I showed you how to display the contents of the images table in a web. | 12 CREATING A DYNAMIC ONLINE GALLERY PHP SOLUTIONS DYNAMIC WEB DESIGN MADE EASY What this chapter covers Why storing images in a database is a bad idea and what you should do instead Planning the layout of a dynamic gallery Displaying a fixed number of results in a row Limiting the number of records retrieved at a time Paging through a long set of results In the last chapter I showed you how to display the contents of the images table in a web page. It didn t look very attractive text in an unadorned table. However I hope you will have realized by now that all you need to do to display the images themselves is add img tags to the underlying XHTML and you ll end up with something far more impressive. In fact by the end of this chapter you will have created the mini photo gallery shown in Figure 12-1. Figure 12-1. The mini photo gallery is driven entirely by drawing information from a database. Although it uses images the gallery demonstrates some cool features that you will want to incorporate into text-driven pages too. For instance the grid of thumbnail images on the left displays two images per row. Just by changing two numbers you can make the grid as many columns wide and as many rows deep as you like. Clicking one of the thumbnails replaces the main image and caption. It s the same page that reloads but exactly the same technique is used to create online catalogs that take you to another page with more details about a product. The Next link at the foot of the thumbnails grid shows you the next set of photographs using exactly the same technique as you use to page through a long set of search results. This gallery isn t just a pretty face or two . . . First of all a word about images and databases. 320 CREATING A DYNAMIC ONLINE GALLERY Why not store images in a database The images table contains only filenames and captions but not the images themselves. Even though I said in the last chapter that you can always add new columns or tables to a database when new .

TỪ KHÓA LIÊN QUAN