Specifications
LISTING 26.3 headlines.php Shows the Most Recent Headline from Each Page
<?
include (“include_fns.php”);
include (“header.php”);
$conn = db_connect();
$pages_sql = “select * from pages order by code”;
$pages_result = mysql_query($pages_sql, $conn);
while ($pages = mysql_fetch_array($pages_result)) {
$story_sql = “select * from stories
where page = ‘$pages[code]’
and published is not null
order by published desc”;
$story_result = mysql_query($story_sql, $conn);
if (mysql_num_rows($story_result)) {
$story = mysql_fetch_array($story_result);
echo “<TABLE BORDER=0 WIDTH=400>”;
echo “<TR>”;
echo “<TD ROWSPAN=2 WIDTH=100>”;
if ($story[picture])
echo “<IMG SRC=\”resize_image.php?image=$story[picture]\”>”;
echo “</TD>”;
echo “<TD>”;
echo “<H3>$pages[description]</H3>”;
echo $story[headline];
echo “</TD>”;
echo “</TR>”;
echo “<TR><TD ALIGN=RIGHT>”;
echo “<A HREF=\”page.php?page=$pages[code]\”>”;
echo “<FONT SIZE=1>Read more $pages[code] ...</FONT>”;
echo “</A>”;
echo “</TABLE>”;
}
}
include (“footer.php”);
?>
This script, as with all the public scripts, includes header.php at the start and footer.php at
the end. Any output generated by the script is therefore displayed within the main content cell
in the page.
Building a Content Management System
C
HAPTER 26
26
CONTENT
MANAGEMENT
SYSTEMS
599
32 7842 ch26 3/6/01 3:36 PM Page 599










