Creating PHP Files
We will have to create two PHP files (forum.php & node.php) to make our discussion forum work.
Please open any text editor and create the two files with the source code below (the code is well documented to tell you what each line does), save this file in C:INETPUBWWWROOT folder
Here is the code for first PHP file (forum.php)
<?php
// This is the DSN we have create for our database
$connect = odbc_connect("forum", "root", "");
?>
<html>
<body>
Discussion Forum using PHP/Access under IIS<br /><br />
<a href="node.php?node=0">Post New Message</a>
<?php
shownode(0); // display all the main threads
// This function is a recursive function which shall display all the br /anches
// and sub br /anches of the threads
function shownode($nodecode)
{
global $connect; // using the global variable for connection
// Get a list of all the sub nodes which specific parentcode
$noderesult = odbc_exec($connect,"select * from forum where parentcode = $nodecode");
echo '<ul type="disc">';
while(odbc_fetch_row($noderesult)) // get all the rows
{
$code = odbc_result($noderesult,"code");
$title = odbc_result($noderesult,"title");
$uname = odbc_result($noderesult,"uname");
$email = odbc_result($noderesult,"email");
echo "<li>";
echo "<a href="node.php?node=$code"> $title </a>";
echo "-- by ($uname) $email<br />";
shownode($code);
}
echo "</ul>";
}
?>
</body>
</html>