Specifications
The hard work is done by two database queries. First,
select * from pages order by code
will retrieve the list of pages that are in the database. Next the contents of the loop
select * from stories
where page = ‘$pages[code]’
and published is not null
order by published desc
is executed to find the stories on that page in reverse order of the date published.
Figure 26.3 shows the output from headline.php using the sample application data.
Building Practical PHP and MySQL Projects
P
ART V
600
FIGURE 26.3
Showing the headlines from each page within the site.
Next to each headline, a link is generated in the following form:
<A HREF=”page.php?page=1”><FONT SIZE=1>Read more news...</FONT></A>
This is done within the previous loop so that the query string value of $page and the page
name are printed next to the relevant headline. Clicking this link takes the visitor to
page.php—the full list of stories for the particular page. The source for page.php can be found
in Listing 26.4.
32 7842 ch26 3/6/01 3:36 PM Page 600










