I asked a similar questiona while back and finally got an emailed reply from someone. THis is the script they sent me and it works great.
<?
// start page
print_header();
// show posts
$topID = 0;
ListPosts($topID);
// end page
print_footer();
exit;
/////////////////////////////////////////////////////////////////////
//
// You'll need to look at the following:
//
// 1. Put in your MySQL values
// 2. You'll need to change the print statement that actually
// lists the post so the anchor href points to the page
// that displays the post. I have written it to pass the
// post ID to the display script. You can also format it
// differently if you want
function ListPosts($parentID)
{
/*
This function will display a list of all the forum posts
in a tree format.
Parameters:
$parentID parent post ID
*/
$SERVER = "localhost";
$USER = "";
$PASSWORD = "";
$DBASE = "";
// do MySQL initialization
$conn = mysql_connect($SERVER,$USER,$PASSWORD);
if(!$conn)
{
echo "Connection attempt failed.";
exit;
}
elseif(!mysql_select_db($DBASE,$conn))
{
echo "Database Select failed.";
exit;
}
// be sure post ID is an integer
$parentID = intval($parentID);
// set up and perform query to get child posts
$sql = "SELECT PostID, PostTitle, PostedBy, DateTime
FROM Posts
WHERE ParentPostID = $parentID
ORDER BY DateTime DESC";
$results = mysql_query($sql,$conn);
// if found child posts, display them
if (mysql_num_rows($results) > 0)
{
// start list for current level of posts; this does the indenting
print "<br><ul>\n";
// display results and loop through them to get child posts
while ( $row = mysql_fetch_array($results))
{
$postID = $row["PostID"];
$postTitle = $row["PostTitle"];
$postedBy = $row["PostedBy"];
$dateTime = $row["DateTime"];
print "<li><A HREF=\"showpost.php?postID=$postID\">$postTitle</A>
$postedBy $dateTime</li>";
ListPosts($postID);
}
// end current list
print "</ul>";
}
// finished
return;
}
function print_header()
{
/
This routine creates the header for the page
/
print "\n
<head>\n
<title>My Forum</title>\n
</head>\n
<body bgcolor=\"#FFFFFF\" text=\"#000000\" link=\"#0000FF\" alink=\"#00FF00\" vlink=\"#FF00FF\">\n
<br><br>\n
<center><h1>My Forum</h1></center>\n
<br><br>\n";
return;
}
function print_footer()
{
/
This routine creates the footer for the page
/
print "</body>\n
\n";
return;
}
?>